needsCompleteGeneration() public method

Example #1
0
 public function testAccessors()
 {
     $context = new GenerationContext();
     $this->assertTrue($context->isFirstPass());
     $this->assertFalse($context->needsCompleteGeneration());
     $context->setToSecondPass();
     $this->assertFalse($context->isFirstPass());
     $this->assertFalse($context->needsCompleteGeneration());
     $context->markAsNeedsCompleteGeneration();
     $this->assertFalse($context->isFirstPass());
     $this->assertTrue($context->needsCompleteGeneration());
     $context->unmarkAsNeedsCompleteGeneration();
     $this->assertFalse($context->isFirstPass());
     $this->assertFalse($context->needsCompleteGeneration());
 }
 /**
  * @param FixtureIdInterface|FixtureInterface $referredFixture
  * @param string                              $referredFixtureId
  * @param ResolvedFixtureSet                  $fixtureSet
  * @param GenerationContext                   $context
  *
  * @return ResolvedValueWithFixtureSet
  */
 private function resolveReferredFixture(FixtureIdInterface $referredFixture, string $referredFixtureId, ResolvedFixtureSet $fixtureSet, GenerationContext $context) : ResolvedValueWithFixtureSet
 {
     if ($fixtureSet->getObjects()->has($referredFixture)) {
         $referredObject = $fixtureSet->getObjects()->get($referredFixture);
         if ($referredObject instanceof CompleteObject || false === $context->needsCompleteGeneration()) {
             return new ResolvedValueWithFixtureSet($referredObject->getInstance(), $fixtureSet);
         }
     }
     // Object is either not completely generated or has not been generated at all yet
     if (false === $referredFixture instanceof FixtureInterface) {
         throw FixtureNotFoundExceptionFactory::create($referredFixtureId);
     }
     $context->markIsResolvingFixture($referredFixtureId);
     $objects = $this->generator->generate($referredFixture, $fixtureSet, $context);
     $fixtureSet = $fixtureSet->withObjects($objects);
     return new ResolvedValueWithFixtureSet($fixtureSet->getObjects()->get($referredFixture)->getInstance(), $fixtureSet);
 }
Example #3
0
 private function isObjectComplete(FixtureInterface $fixture, ObjectInterface $object, GenerationContext $context) : bool
 {
     return $object instanceof CompleteObject || $context->needsCompleteGeneration() || false === $context->isFirstPass() || false === $context->needsCompleteGeneration() && $fixture->getSpecs()->getProperties()->isEmpty() && $fixture->getSpecs()->getMethodCalls()->isEmpty();
 }