/** * @cover ::execute * @cover ::getExecutor */ public function testExecuteWithTruncate() { $fixtures = ['fixture1']; $objectManagerProphecy = $this->prophesize('Doctrine\\Common\\Persistence\\ObjectManager'); $eventManagerProphecy = $this->prophesize('Doctrine\\Common\\EventManager'); $eventManagerProphecy->addEventSubscriber(Argument::any())->will(function ($args) { return 'Doctrine\\Common\\DataFixtures\\Event\\Listener\\ORMReferenceListener' === get_class($args[0]); }); $eventManagerProphecy->addEventSubscriber(Argument::any())->will(function ($args) { return 'Doctrine\\Common\\DataFixtures\\Event\\Listener\\MongoDBReferenceListener' === get_class($args[0]); }); $entityManagerProphecy = $this->prophesize('Doctrine\\ORM\\EntityManagerInterface'); $entityManagerProphecy->getEventManager()->willReturn($eventManagerProphecy->reveal()); $entityManagerProphecy->transactional(Argument::any())->shouldBeCalledTimes(1); $mongodbDocumentManagerProphecy = $this->prophesize('Doctrine\\ODM\\MongoDB\\DocumentManager'); $mongodbDocumentManagerProphecy->getEventManager()->willReturn($eventManagerProphecy->reveal()); $phpcrDocumentManagerProphecy = $this->prophesize('Doctrine\\ODM\\PHPCR\\DocumentManager'); $loaderProphecy = $this->prophesize('Hautelook\\AliceBundle\\Alice\\DataFixtures\\LoaderInterface'); $loaderProphecy->load(Argument::any(), $fixtures)->will(function ($arg1) { return 'Nelmio\\Alice\\Persister\\Doctrine' === get_class($arg1[0]); }); $loggerProphecy = $this->prophesize('callable'); $fixturesExecutor = new FixturesExecutor(); try { $fixturesExecutor->execute($objectManagerProphecy->reveal(), $loaderProphecy->reveal(), $fixtures, $loggerProphecy->reveal(), true); $this->fail('Expected \\InvalidArgumentException to be thrown.'); } catch (\InvalidArgumentException $exception) { // Expected result } $fixturesExecutor->execute($entityManagerProphecy->reveal(), $loaderProphecy->reveal(), $fixtures, $loggerProphecy->reveal(), true); $fixturesExecutor->execute($mongodbDocumentManagerProphecy->reveal(), $loaderProphecy->reveal(), $fixtures, $loggerProphecy->reveal(), true); $fixturesExecutor->execute($phpcrDocumentManagerProphecy->reveal(), $loaderProphecy->reveal(), $fixtures, $loggerProphecy->reveal(), true); }
public function loadFixtures($fixtures) { codecept_debug("Loading fixtures"); $this->fixturesExecutor->execute($this->entityManager, $this->fixturesLoader, $fixtures, $this->config['append'], null); }