I'm starting to use this library to feed fixtures to my tests and I found myself with a problem. I need to create a fixture of a user that has a company, I've tried using the getReference method with 2 fixture files and then I tried this:
<?php
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Persistence\ObjectManager;
final class UserFixture implements FixtureInterface
{
public User $user
public Company $company;
public function __construct()
{
$this->company = Company::create('Company name');
$this->user = User::create('email');
}
public function load(ObjectManager $manager)
{
$manager->persist($this->company);
$manager->persist($this->employee);
$manager->flush();
}
}
But both times when I do a find in my code I always get the proxy instead of the entity itself, usually it would not be a problem but in this case I'm using ReflectionClass to get the list of properties and I only get the list doctrine Proxy's properties.
Is there some way to avoid that? Maybe creating fixture some other way, or clearing the cache somehow?
Hi,
I'm starting to use this library to feed fixtures to my tests and I found myself with a problem. I need to create a fixture of a user that has a company, I've tried using the
getReference
method with 2 fixture files and then I tried this:But both times when I do a find in my code I always get the proxy instead of the entity itself, usually it would not be a problem but in this case I'm using
ReflectionClass
to get the list of properties and I only get the list doctrine Proxy's properties.Is there some way to avoid that? Maybe creating fixture some other way, or clearing the cache somehow?
Thanks in advance, I'm kinda lost right now.