Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\SimpleSpecificationsDenormalizerTest::testCanDenormalizeProperties PHP Method

testCanDenormalizeProperties() public method

    public function testCanDenormalizeProperties()
    {
        $fixture = new FakeFixture();
        $specs = ['username' => '<name()>', 'name' => 'bob'];
        $flagParserProphecy = $this->prophesize(FlagParserInterface::class);
        $flagParserProphecy->parse('username')->willReturn($usernameFlags = new FlagBag('parsed_username'));
        $flagParserProphecy->parse('name')->willReturn($nameFlags = new FlagBag('parsed_name'));
        /** @var FlagParserInterface $flagParser */
        $flagParser = $flagParserProphecy->reveal();
        $propertyDenormalizerProphecy = $this->prophesize(PropertyDenormalizerInterface::class);
        $propertyDenormalizerProphecy->denormalize($fixture, 'parsed_username', '<name()>', $usernameFlags)->willReturn($usernameProp = new Property('username', '<name()>'));
        $propertyDenormalizerProphecy->denormalize($fixture, 'parsed_name', 'bob', $nameFlags)->willReturn($nameProp = new Property('name', 'bob'));
        /** @var PropertyDenormalizerInterface $propertyDenormalizer */
        $propertyDenormalizer = $propertyDenormalizerProphecy->reveal();
        $expected = new SpecificationBag(null, (new PropertyBag())->with($usernameProp)->with($nameProp), new MethodCallBag());
        $denormalizer = new SimpleSpecificationsDenormalizer(new FakeConstructorDenormalizer(), $propertyDenormalizer, new FakeCallsDenormalizer());
        $actual = $denormalizer->denormalize(new FakeFixture(), $flagParser, $specs);
        $this->assertEquals($expected, $actual);
        $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(2);
        $propertyDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(2);
    }