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()); }
/** * @inheritdoc */ public function generate(FixtureInterface $fixture, ResolvedFixtureSet $fixtureSet, GenerationContext $context) : ObjectBag { if ($context->isFirstPass()) { $fixtureSet = $this->instantiator->instantiate($fixture, $fixtureSet, $context)->getObjects(); if (false === $context->needsCompleteGeneration()) { return $fixtureSet; } } $fixtureSet = $this->completeObject($fixture, $fixtureSet, $context); return $fixtureSet->getObjects(); }
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(); }