예제 #1
0
 public function testFixtureManager()
 {
     $this->loader->expects($this->once())->method('load')->will($this->returnValue(new FixtureCollection()));
     $this->executor->expects($this->once())->method('execute');
     $this->persister->expects($this->once())->method('flush');
     $this->eventDispatcher->expects($this->exactly(5))->method('dispatch');
     $this->fixtureManager->load(null);
 }
예제 #2
0
 /**
  *
  * @param ExecutorInterface $executor
  */
 public function __construct(ExecutorInterface $executor)
 {
     parent::__construct();
     $this->executor = $executor;
     $this->register('object', function ($name, $key) {
         return sprintf('object("%s", "%s")', $name, $key);
     }, function ($arguments, $name, $key) use($executor) {
         $collection = $arguments['collection'];
         $fixtureData = $collection->get($name)->get($key);
         if (!($object = $fixtureData->getObject())) {
             $object = $executor->createObject($collection, $name, $key);
         }
         return $object;
     });
 }
예제 #3
0
 /**
  *
  * @param string $path
  * @param array $options
  */
 public function load($path = null, array $options = array())
 {
     $event = new FixtureEvent($this, $options);
     $this->eventDispatcher->dispatch(FixtureEvents::onPreLoad, $event);
     $options = $event->getOptions();
     $collection = $this->loader->load($path);
     $event = new FixtureCollectionEvent($this, $collection, $options);
     $this->eventDispatcher->dispatch(FixtureEvents::onPreExecute, $event);
     $collection = $event->getCollection();
     $options = $event->getOptions();
     $this->replaceMultiPlaceholder($collection);
     $this->replaceServicePlaceholder($collection);
     $event = new FixtureCollectionEvent($this, $collection, $options);
     $this->eventDispatcher->dispatch(FixtureEvents::onPreExecute, $event);
     $collection = $event->getCollection();
     $options = $event->getOptions();
     $this->executor->execute($collection);
     $event = new FixtureCollectionEvent($this, $collection, $options);
     $this->eventDispatcher->dispatch(FixtureEvents::onPostExecute, $event);
     $collection = $event->getCollection();
     $options = $event->getOptions();
     if (isset($options['dry_run']) && $options['dry_run'] == true) {
         return;
     }
     $this->persist($collection);
     $event = new FixtureCollectionEvent($this, $collection, $options);
     $this->eventDispatcher->dispatch(FixtureEvents::onPostPersist, $event);
 }