ApiPlatform\Core\Tests\NelmioApiDoc\Parser\ApiPlatformParserTest::testSupportsAttributeNormalization PHP Method

testSupportsAttributeNormalization() public method

    public function testSupportsAttributeNormalization()
    {
        $resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
        $resourceMetadataFactoryProphecy->create('Acme\\CustomAttributeDummy')->willReturn(new ResourceMetadata('dummy', 'dummy', null, ['get' => ['method' => 'GET', 'normalization_context' => ['groups' => ['custom_attr_dummy_get']]], 'put' => ['method' => 'PUT', 'denormalization_context' => ['groups' => ['custom_attr_dummy_put']]], 'delete' => ['method' => 'DELETE']], []))->shouldBeCalled();
        $resourceMetadataFactory = $resourceMetadataFactoryProphecy->reveal();
        $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
        $propertyNameCollectionFactoryProphecy->create('Acme\\CustomAttributeDummy', Argument::cetera())->willReturn(new PropertyNameCollection(['id', 'name']))->shouldBeCalled();
        $propertyNameCollectionFactory = $propertyNameCollectionFactoryProphecy->reveal();
        $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
        $idPropertyMetadata = (new PropertyMetadata())->withType(new Type(Type::BUILTIN_TYPE_INT, false))->withDescription('The id.')->withReadable(true)->withWritable(false)->withRequired(true);
        $propertyMetadataFactoryProphecy->create('Acme\\CustomAttributeDummy', 'id')->willReturn($idPropertyMetadata)->shouldBeCalled();
        $namePropertyMetadata = (new PropertyMetadata())->withType(new Type(Type::BUILTIN_TYPE_STRING, false))->withDescription('The dummy name.')->withReadable(true)->withWritable(true)->withRequired(true);
        $propertyMetadataFactoryProphecy->create('Acme\\CustomAttributeDummy', 'name')->willReturn($namePropertyMetadata)->shouldBeCalled();
        $propertyMetadataFactory = $propertyMetadataFactoryProphecy->reveal();
        $apiPlatformParser = new ApiPlatformParser($resourceMetadataFactory, $propertyNameCollectionFactory, $propertyMetadataFactory);
        $actual = $apiPlatformParser->parse(['class' => sprintf('%s:%s:%s', ApiPlatformParser::OUT_PREFIX, 'Acme\\CustomAttributeDummy', 'get')]);
        $this->assertEquals(['id' => ['dataType' => DataTypes::INTEGER, 'required' => false, 'description' => 'The id.', 'readonly' => true], 'name' => ['dataType' => DataTypes::STRING, 'required' => true, 'description' => 'The dummy name.', 'readonly' => false]], $actual);
    }