Nelmio\Alice\Throwable\Exception\InvalidArgumentExceptionFactory::createForFixtureExtendingANonTemplateFixture PHP Method

createForFixtureExtendingANonTemplateFixture() public static method

public static createForFixtureExtendingANonTemplateFixture ( Nelmio\Alice\FixtureInterface $fixture, string $fixtureId ) : InvalidArgumentException
$fixture Nelmio\Alice\FixtureInterface
$fixtureId string
return InvalidArgumentException
    public static function createForFixtureExtendingANonTemplateFixture(FixtureInterface $fixture, string $fixtureId) : \InvalidArgumentException
    {
        return new \InvalidArgumentException(sprintf('Fixture "%s" extends "%2$s" but "%2$s" is not a template.', $fixture->getId(), $fixtureId));
    }

Usage Example

Example #1
0
 /**
  * @param TemplatingFixture    $fixture
  * @param FixtureReference[]   $extendedFixtureReferences
  * @param FixtureBag           $unresolvedFixtures
  * @param TemplatingFixtureBag $resolvedFixtures
  * @param ResolvingContext     $context
  *
  * @throws FixtureNotFoundException
  *
  * @return array The first element is a FixtureBag with all the extended fixtures and the second is a
  *               TemplatingFixtureBag which may contain new fixtures (from the resolution)
  */
 private function resolveExtendedFixtures(TemplatingFixture $fixture, array $extendedFixtureReferences, FixtureBag $unresolvedFixtures, TemplatingFixtureBag $resolvedFixtures, ResolvingContext $context) : array
 {
     $fixtures = new FixtureBag();
     foreach ($extendedFixtureReferences as $reference) {
         $fixtureId = $reference->getId();
         $context->add($fixtureId);
         if (false === $unresolvedFixtures->has($fixtureId)) {
             throw FixtureNotFoundExceptionFactory::create($fixtureId);
         }
         if ($resolvedFixtures->has($fixtureId)) {
             if (false === $resolvedFixtures->hasTemplate($fixtureId)) {
                 throw InvalidArgumentExceptionFactory::createForFixtureExtendingANonTemplateFixture($fixture, $fixtureId);
             }
             $fixtures = $fixtures->with($resolvedFixtures->getTemplate($fixtureId));
             continue;
         }
         $unresolvedFixture = $unresolvedFixtures->get($fixtureId);
         if (false === $unresolvedFixture instanceof TemplatingFixture) {
             throw InvalidArgumentExceptionFactory::createForFixtureExtendingANonTemplateFixture($fixture, $fixtureId);
         }
         $resolvedFixtures = $this->resolve($unresolvedFixtures->get($fixtureId), $unresolvedFixtures, $resolvedFixtures, $context);
         $fixtures = $fixtures->with($resolvedFixtures->get($fixtureId));
     }
     return [$fixtures, $resolvedFixtures];
 }
All Usage Examples Of Nelmio\Alice\Throwable\Exception\InvalidArgumentExceptionFactory::createForFixtureExtendingANonTemplateFixture