Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\SimpleDenormalizer::denormalize PHP Method

denormalize() public method

public denormalize ( FixtureBag $builtFixtures, string $className, string $unparsedFixtureId, array $specs, FlagBag $flags ) : FixtureBag
$builtFixtures Nelmio\Alice\FixtureBag
$className string
$unparsedFixtureId string
$specs array
$flags Nelmio\Alice\Definition\FlagBag
return Nelmio\Alice\FixtureBag
    public function denormalize(FixtureBag $builtFixtures, string $className, string $unparsedFixtureId, array $specs, FlagBag $flags) : FixtureBag
    {
        if (null === $this->flagParser) {
            throw FlagParserExceptionFactory::createForExpectedMethodToBeCalledIfHasAParser(__METHOD__);
        }
        $idFlags = $this->flagParser->parse($unparsedFixtureId);
        $fixture = new SimpleFixture($idFlags->getKey(), $className, new SpecificationBag(null, new PropertyBag(), new MethodCallBag()));
        $fixture = $fixture->withSpecs($this->specsDenormalizer->denormalize($fixture, $this->flagParser, $specs));
        return $builtFixtures->with(new TemplatingFixture(new SimpleFixtureWithFlags($fixture, $idFlags->mergeWith($flags))));
    }

Usage Example

 /**
  * @expectedException \Nelmio\Alice\Throwable\Exception\FixtureBuilder\Denormalizer\FlagParser\FlagParserNotFoundException
  * @expectedExceptionMessage Expected method "Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\SimpleDenormalizer::denormalize" to be called only if it has a flag parser.
  */
 public function testCannotDenormalizeFixtureIfHasNoFlagParser()
 {
     /** @var SpecificationsDenormalizerInterface $specsDenormalizer */
     $specsDenormalizer = $this->prophesize(SpecificationsDenormalizerInterface::class)->reveal();
     $denormalizer = new SimpleDenormalizer($specsDenormalizer);
     $denormalizer->denormalize(new FixtureBag(), 'Nelmio\\Alice\\Entity\\User', 'user0', [], new FlagBag(''));
 }