Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\SimpleDenormalizerTest::testDenormalizesValuesToCreateANewFixtureObjectAndAddItToTheListOfFixturesReturned PHP Метод

testDenormalizesValuesToCreateANewFixtureObjectAndAddItToTheListOfFixturesReturned() публичный Метод

    public function testDenormalizesValuesToCreateANewFixtureObjectAndAddItToTheListOfFixturesReturned()
    {
        $fixtures = new FixtureBag();
        $className = 'Nelmio\\Alice\\Entity\\User';
        $reference = 'user_base';
        $specs = ['username' => '<name()>'];
        $flags = new FlagBag('');
        $flagParserProphecy = $this->prophesize(FlagParserInterface::class);
        $flagParserProphecy->parse($reference)->willReturn(new FlagBag('user_base'));
        /** @var FlagParserInterface $flagParser */
        $flagParser = $flagParserProphecy->reveal();
        $specsDenormalizerProphecy = $this->prophesize(SpecificationsDenormalizerInterface::class);
        $expectedSpecs = new SpecificationBag(null, new PropertyBag(), new MethodCallBag());
        $specsDenormalizerProphecy->denormalize(Argument::type(SimpleFixture::class), $flagParser, $specs)->willReturn($expectedSpecs);
        /** @var SpecificationsDenormalizerInterface $specsDenormalizer */
        $specsDenormalizer = $specsDenormalizerProphecy->reveal();
        $denormalizer = (new SimpleDenormalizer($specsDenormalizer))->withFlagParser($flagParser);
        $actual = $denormalizer->denormalize($fixtures, $className, $reference, $specs, $flags);
        $expected = $fixtures->with(new TemplatingFixture(new SimpleFixtureWithFlags(new SimpleFixture($reference, $className, $expectedSpecs), new FlagBag('user_base'))));
        $this->assertEquals($expected, $actual);
        $flagParserProphecy->parse(Argument::any())->shouldHaveBeenCalledTimes(1);
        $specsDenormalizerProphecy->denormalize(Argument::cetera())->shouldHaveBeenCalledTimes(1);
    }