Nelmio\Alice\Generator\ObjectGenerator\SimpleObjectGeneratorTest::testGenerate PHP Method

testGenerate() public method

public testGenerate ( )
    public function testGenerate()
    {
        $this->markTestIncomplete('TODO');
        $fixture = new SimpleFixture('dummy', \stdClass::class, SpecificationBagFactory::create());
        $set = ResolvedFixtureSetFactory::create();
        $context = new GenerationContext();
        $context->markIsResolvingFixture('foo');
        $instance = new \stdClass();
        $instantiatedObject = new SimpleObject($fixture->getId(), $instance);
        $instantiatorProphecy = $this->prophesize(InstantiatorInterface::class);
        $instantiatorProphecy->instantiate($fixture, $set, $context)->willReturn($setWithInstantiatedObject = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with($instantiatedObject)));
        /** @var InstantiatorInterface $instantiator */
        $instantiator = $instantiatorProphecy->reveal();
        $hydratedInstance = clone $instance;
        $hydratedInstance->hydrated = true;
        $hydratedObject = new SimpleObject($fixture->getId(), $hydratedInstance);
        $hydratorProphecy = $this->prophesize(HydratorInterface::class);
        $hydratorProphecy->hydrate($instantiatedObject, $setWithInstantiatedObject, $context)->willReturn($setWithHydratedObject = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with($hydratedObject)));
        /** @var HydratorInterface $hydrator */
        $hydrator = $hydratorProphecy->reveal();
        $instanceAfterCalls = clone $hydratedInstance;
        $instanceAfterCalls->calls = true;
        $objectAfterCalls = new SimpleObject($fixture->getId(), $instanceAfterCalls);
        $callerProphecy = $this->prophesize(CallerInterface::class);
        $callerProphecy->doCallsOn($hydratedObject, $setWithHydratedObject)->willReturn($setWithObjectAfterCalls = ResolvedFixtureSetFactory::create(null, null, (new ObjectBag())->with($objectAfterCalls)));
        /** @var CallerInterface $caller */
        $caller = $callerProphecy->reveal();
        $generator = new SimpleObjectGenerator(new FakeValueResolver(), $instantiator, $hydrator, $caller);
        $objects = $generator->generate($fixture, $set, $context);
        $this->assertEquals($setWithObjectAfterCalls->getObjects(), $objects);
        $instantiatorProphecy->instantiate(Argument::cetera())->shouldHaveBeenCalledTimes(1);
        $hydratorProphecy->hydrate(Argument::cetera())->shouldHaveBeenCalledTimes(1);
        $callerProphecy->doCallsOn(Argument::cetera())->shouldHaveBeenCalledTimes(1);
    }