Example #1
0
 /**
  *
  * @param  string $path
  * @param array $options
  * @return FixtureCollection
  */
 public function load($path, array $options = array())
 {
     $collection = $this->loader->load($path, $options);
     if (!isset($options['tags'])) {
         return $collection;
     }
     $filter = $options['tags'];
     if (!is_array($filter)) {
         $filter = array($filter);
     }
     if (empty($filter)) {
         return $collection;
     }
     foreach ($collection as $fixture) {
         $tags = $fixture->getProperties()->get('tags');
         if (!$tags || !is_array($tags)) {
             $collection->remove($fixture->getName());
             continue;
         }
         foreach ($tags as $tag) {
             if (in_array($tag, $filter)) {
                 continue 2;
             }
         }
         $collection->remove($fixture->getName());
     }
     return $collection;
 }
 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);
 }
Example #3
0
 /**
  *
  * @param  string|array $path
  * @param  array $options
  * @return FixtureCollection
  */
 public function load($path, array $options = array())
 {
     if (is_array($path)) {
         $this->trace = array_merge($this->trace, $path);
     } else {
         $this->trace[] = $path;
     }
     return $this->loader->load($path);
 }
Example #4
0
 /**
  *
  * @param mixed $path
  * @param array $options
  * @return FixtureCollection
  */
 public function load($path, array $options = array())
 {
     if (!is_array($path)) {
         return $this->loader->load($path, $options);
     }
     $collection = new FixtureCollection();
     foreach ($path as $p) {
         $c = $this->loader->load($p, $options);
         $collection->merge($c);
     }
     return $collection;
 }
Example #5
0
 /**
  *
  * @param  string|array $path
  * @param array $options
  * @return FixtureCollection
  */
 public function load($path, array $options = array())
 {
     if (empty($path)) {
         $path = $this->getFixturesByBundles();
     } elseif (!is_array($path)) {
         $path = array($path);
     }
     $collection = new FixtureCollection();
     foreach ($path as $p) {
         $collection->merge($this->loader->load($p));
     }
     return $collection;
 }
Example #6
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);
 }
Example #7
0
 /**
  *
  * @param  string|array $path
  * @param array $options
  * @return FixtureCollection
  */
 public function load($path, array $options = array())
 {
     if (!file_exists($path)) {
         throw new \RuntimeException(sprintf('"%s" dir or file not found', $path));
     }
     if (is_file($path)) {
         return $this->loader->load($path, $options);
     }
     $finder = new Finder();
     $finder->in($path)->files();
     $collection = new FixtureCollection();
     foreach ($finder as $file) {
         $col = $this->loader->load(realpath($file->getPathname()), $options);
         $collection->merge($col);
     }
     return $collection;
 }