public function testProcessor() { $this->factoryMock->expects($this->any())->method('getLoader')->with('en_EN')->will($this->returnValue(new Loader())); $this->managerRegistryMock->expects($this->any())->method('getManagerForClass')->will($this->returnValue($this->objectManagerMock)); $this->processorMock->expects($this->exactly(11))->method('preProcess'); $this->processorMock->expects($this->exactly(11))->method('postProcess'); $this->manager->addProcessor($this->processorMock); $set = $this->manager->createFixtureSet(); $set->setSeed(null); $set->addFile(__DIR__ . '/../testdata/part_1.yml', 'yaml'); $this->manager->load($set); }
/** * @param array $files * @param bool $doDrop */ public function load(array $files, $doDrop = true) { try { $this->em->getConnection()->beginTransaction(); $userProcessor = new UserProcessor(realpath(SystemUtil::getRootDir() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR), $this->userService, $this->mimeTypeGuesser, $this->extensionGuesser); // Create Alice manager and fixture set $this->fixtureManager->addProcessor($userProcessor); $set = $this->fixtureManager->createFixtureSet(); // Add the fixture files foreach ($files as $file) { $set->addFile($file, 'yaml'); } $set->setDoDrop($doDrop); $set->setDoPersist(true); $set->setSeed(1337 + 42); // TODO Keep Module data intact $bundles = $this->em->getRepository("CampaignChain\\CoreBundle\\Entity\\Bundle")->findAll(); $modules = $this->em->getRepository("CampaignChain\\CoreBundle\\Entity\\Module")->findAll(); if ($this->fixtureManager->load($set)) { // TODO: Restore modules data foreach ($bundles as $bundle) { $this->em->persist($bundle); } foreach ($modules as $module) { $this->em->persist($module); } $this->em->flush(); $this->em->getConnection()->commit(); return true; } return false; } catch (\Exception $e) { $this->em->getConnection()->rollback(); $this->setException($e); return false; } }