You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I had problem with load fixtures in behat based functional tests. When I load fixture class with Dependency Injection inside it, it works fine, but when I try to load another fixture which depends on first one by getDependencies() method I take following error:
Type error: Too few arguments to function App\DataFixtures\UserFixtures::__construct(), 0 passed in vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php on line 231 and exactly 2 expected (Behat\Testwork\Call\Exception\FatalThrowableError)
Below is code from behat loading process and fixtures :
Behat loader:
`
private function loadFixtures($fixturesNames)
{
//use Doctrine\Common\DataFixtures\Loader;
//I tried $loader = new ContainerAwareLoader($this->kernel->getContainer()); too but with the same result :(
$loader = new Loader();
foreach ($fixturesNames as $fixtureName) {
$fixture = $this->kernel->getContainer()->get('App\DataFixtures\\'.$fixtureName.'Fixtures');
$loader->addFixture($fixture);
}
$executor = new ORMExecutor($this->getEntityManager());
$executor->execute($loader->getFixtures(), true);
}
`
Fixture one (if I run this fixture in bahat alone it works)
`
class UserFixtures extends BaseFixture
{
private $passwordEncoder;
private $userImageManager;
//That contructor makes problem
public function __construct(UserPasswordEncoderInterface $passwordEncoder, ImagesManagerInterface $userImageManager)
{
$this->passwordEncoder = $passwordEncoder;
$this->userImageManager = $userImageManager;
}
`
Fixture 2: class FooFixtures extends BaseFixture implements DependentFixtureInterface { public function getDependencies() { //When I do that if, behat works ok, but if it's possible I don't want that if here because some fixtures needs only UserFixtures::class and I cannot push empty array here if ($_ENV['APP_ENV'] !== 'test') { return [ UserFixtures::class, Foo2Fixtures::class, Foo3Fixtures::class, Foo4Fixtures::class, ]; } else { return [ //UserFixtures::class, Foo2Fixtures::class, Foo3Fixtures::class, Foo4Fixtures::class, ]; } }
I'm not sure it strictly depends of DoctrineFixturesBundle, but I look for answer and maybe someone from here know the solution. Thanks for any reply.
The text was updated successfully, but these errors were encountered:
Hi,
I had problem with load fixtures in behat based functional tests. When I load fixture class with Dependency Injection inside it, it works fine, but when I try to load another fixture which depends on first one by getDependencies() method I take following error:
Below is code from behat loading process and fixtures :
Behat loader:
`
private function loadFixtures($fixturesNames)
{
//use Doctrine\Common\DataFixtures\Loader;
//I tried $loader = new ContainerAwareLoader($this->kernel->getContainer()); too but with the same result :(
`
Fixture one (if I run this fixture in bahat alone it works)
`
class UserFixtures extends BaseFixture
{
`
Fixture 2:
class FooFixtures extends BaseFixture implements DependentFixtureInterface { public function getDependencies() { //When I do that if, behat works ok, but if it's possible I don't want that if here because some fixtures needs only UserFixtures::class and I cannot push empty array here if ($_ENV['APP_ENV'] !== 'test') { return [ UserFixtures::class, Foo2Fixtures::class, Foo3Fixtures::class, Foo4Fixtures::class, ]; } else { return [ //UserFixtures::class, Foo2Fixtures::class, Foo3Fixtures::class, Foo4Fixtures::class, ]; } }
I'm not sure it strictly depends of DoctrineFixturesBundle, but I look for answer and maybe someone from here know the solution. Thanks for any reply.
The text was updated successfully, but these errors were encountered: