get() public method

public get ( string $id ) : Nelmio\Alice\FixtureInterface
$id string Fixture ID.
return Nelmio\Alice\FixtureInterface
Exemplo n.º 1
0
 public function getTemplate(string $id) : FixtureInterface
 {
     if ($this->templates->has($id)) {
         return $this->templates->get($id);
     }
     throw FixtureNotFoundExceptionFactory::create($id);
 }
Exemplo n.º 2
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];
 }