Skip to content

Commit a20bb89

Browse files
authored
Merge pull request #2685 from soyuka/fix-attributes-override-2
Metadata: Attributes default value should be null not an empty array
2 parents 42e0bdc + e74ce08 commit a20bb89

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Metadata/Resource/Factory/AnnotationResourceMetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private function createMetadata(ApiResource $annotation, ResourceMetadata $paren
8585
$annotation->iri,
8686
$annotation->itemOperations,
8787
$annotation->collectionOperations,
88-
$annotation->attributes,
88+
$annotation->attributes ?: null,
8989
$annotation->subresourceOperations,
9090
$annotation->graphql
9191
);

tests/Metadata/Resource/Factory/AnnotationResourceMetadataFactoryTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ public function testCreate($reader, $decorated, string $expectedShortName, strin
4646
$this->assertEquals(['foo' => 'bar'], $metadata->getGraphql());
4747
}
4848

49+
public function testCreateWithoutAttributes()
50+
{
51+
$annotation = new ApiResource([]);
52+
$reader = $this->prophesize(Reader::class);
53+
$reader->getClassAnnotation(Argument::type(\ReflectionClass::class), ApiResource::class)->willReturn($annotation)->shouldBeCalled();
54+
$factory = new AnnotationResourceMetadataFactory($reader->reveal(), null);
55+
$metadata = $factory->create(Dummy::class);
56+
57+
$this->assertNull($metadata->getAttributes());
58+
}
59+
4960
public function getCreateDependencies()
5061
{
5162
$annotation = new ApiResource([

0 commit comments

Comments
 (0)