/**
  * {@inheritdoc}
  *
  * Extended to look for data loaders. If a data loader is found, will take the fixtures from it instead of taking
  * all the fixtures files.
  */
 public function getFixturesFromDirectory($path)
 {
     $fixtures = [];
     $loaders = $this->getDataLoadersFromDirectory($path);
     foreach ($loaders as $loader) {
         $fixtures = array_merge($fixtures, $loader->getFixtures());
     }
     // If no data loader is found, takes all fixtures files
     if (0 === count($loaders)) {
         return parent::getFixturesFromDirectory($path);
     }
     return $fixtures;
 }
 /**
  * @cover ::resolveFixtures
  * @dataProvider unresolvedFixturesProvider
  *
  * @param array $fixtures
  * @param array $expected
  */
 public function testResolveFixtures(array $fixtures, array $expected)
 {
     $finder = new FixturesFinder('DataFixtures/ORM');
     try {
         $actual = $finder->resolveFixtures(self::$kernel, $fixtures);
         if (0 === count($expected)) {
             $this->fail('Expected an exception to be thrown.');
         }
         $this->assertEquals($expected, $actual);
     } catch (\InvalidArgumentException $exception) {
         if (0 !== count($expected)) {
             $this->fail($exception->getMessage());
         }
     } catch (\RuntimeException $exception) {
         if (0 !== count($expected)) {
             $this->fail($exception->getMessage());
         }
         // Otherwise is the expected result
     }
 }
示例#3
0
 /**
  * @param array $bundles
  * @return array
  */
 private function resolveBundles($bundles)
 {
     return $this->fixturesFinder->getFixtures($this->kernel, $this->bundlesResolver->resolveBundles(new Application($this->kernel), $bundles), 'test');
 }