Nelmio\Alice\Generator\Instantiator\InstantiatorRegistryTest::testPassValueResolverAwarenessPropertyToItsInstantiator PHP Method

testPassValueResolverAwarenessPropertyToItsInstantiator() public method

    public function testPassValueResolverAwarenessPropertyToItsInstantiator()
    {
        $resolver = new FakeValueResolver();
        $registry = new InstantiatorRegistry([]);
        $newRegistry = $registry->withValueResolver($resolver);
        $this->assertEquals(new InstantiatorRegistry([]), $registry);
        $this->assertEquals(new InstantiatorRegistry([], $resolver), $newRegistry);
        $registry = new InstantiatorRegistry([new FakeChainableInstantiator()]);
        $newRegistry = $registry->withValueResolver($resolver);
        $this->assertEquals(new InstantiatorRegistry([new FakeChainableInstantiator()]), $registry);
        $this->assertEquals(new InstantiatorRegistry([new FakeChainableInstantiator()], $resolver), $newRegistry);
        $nonAwareInstantiator = new FakeChainableInstantiator();
        $nonAwareInstantiator->foo = 'bar';
        $instantiatorProphecy = $this->prophesize(ChainableInstantiatorInterface::class);
        $instantiatorProphecy->willImplement(ValueResolverAwareInterface::class);
        $instantiatorProphecy->withValueResolver($resolver)->willReturn(new FakeChainableInstantiator());
        /** @var ChainableInstantiatorInterface $instantiator */
        $instantiator = $instantiatorProphecy->reveal();
        $registry = new InstantiatorRegistry([$nonAwareInstantiator, $instantiator]);
        $newRegistry = $registry->withValueResolver($resolver);
        $this->assertEquals(new InstantiatorRegistry([$nonAwareInstantiator, $instantiator]), $registry);
        $this->assertEquals(new InstantiatorRegistry([$nonAwareInstantiator, new FakeChainableInstantiator()], $resolver), $newRegistry);
        $instantiatorProphecy->withValueResolver(Argument::any())->shouldHaveBeenCalledTimes(1);
    }