Skip to content

Commit 6299299

Browse files
committed
test: cleanup
1 parent f63a9c8 commit 6299299

File tree

1 file changed

+18
-70
lines changed

1 file changed

+18
-70
lines changed

tests/Integration/Resource/Denormalizer/ResourceWithAliasesDenormalizerTest.php

+18-70
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Undabot\SymfonyJsonApi\Service\Resource\Builder\ResourceAttributesBuilder;
1717
use Undabot\SymfonyJsonApi\Service\Resource\Builder\ResourceRelationshipsBuilder;
1818
use Undabot\SymfonyJsonApi\Service\Resource\Denormalizer\Exception\MissingDataValueResourceDenormalizationException;
19-
use Undabot\SymfonyJsonApi\Service\Resource\Denormalizer\Exception\ResourceDenormalizationException;
2019
use Undabot\SymfonyJsonApi\Service\Resource\Denormalizer\ResourceDenormalizer;
2120
use Undabot\SymfonyJsonApi\Service\Resource\Factory\ResourceMetadataFactory;
2221
use Undabot\SymfonyJsonApi\Service\Resource\Validation\Constraint\ResourceType;
@@ -26,80 +25,29 @@
2625
*/
2726
class AliasedResourceDto implements ApiModel
2827
{
29-
/**
30-
* @var string
31-
*/
32-
private $id;
33-
34-
/**
35-
* @var string
36-
* @JsonApi\Attribute(name="name")
37-
*/
38-
private $title;
39-
40-
/**
41-
* @var null|string
42-
* @JsonApi\Attribute(name="description")
43-
*/
44-
private $summary;
45-
46-
/**
47-
* @var array
48-
* @JsonApi\ToMany(name="tags", type="tag")
49-
*/
50-
private $tagIds;
51-
52-
/**
53-
* @var null|string
54-
* @JsonApi\ToOne(name="owner", type="person")
55-
*/
56-
private $ownerId;
57-
58-
public function __construct(string $id, string $title, ?string $summary, array $tagIds, ?string $ownerId)
59-
{
60-
$this->id = $id;
61-
$this->title = $title;
62-
$this->summary = $summary;
63-
$this->tagIds = $tagIds;
64-
$this->ownerId = $ownerId;
65-
}
66-
67-
public function getId(): string
68-
{
69-
return $this->id;
70-
}
71-
72-
public function getTitle(): string
73-
{
74-
return $this->title;
75-
}
76-
77-
public function getSummary(): ?string
78-
{
79-
return $this->summary;
80-
}
81-
82-
public function getTagIds(): array
83-
{
84-
return $this->tagIds;
85-
}
86-
87-
public function getOwnerId(): ?string
88-
{
89-
return $this->ownerId;
28+
public function __construct(
29+
public string $id,
30+
/** @JsonApi\Attribute(name="name") */
31+
public string $title,
32+
/** @JsonApi\Attribute(name="description") */
33+
public ?string $summary,
34+
/** @JsonApi\ToMany(name="tags", type="tag") */
35+
public array $tagIds,
36+
/** @JsonApi\ToOne(name="owner", type="person") */
37+
public ?string $ownerId
38+
) {
9039
}
9140
}
9241

9342
/**
9443
* @internal
95-
* @coversNothing
44+
* @covers \Undabot\SymfonyJsonApi\Service\Resource\Denormalizer\ResourceDenormalizer
9645
*
9746
* @small
9847
*/
9948
final class ResourceWithAliasesDenormalizerTest extends TestCase
10049
{
101-
/** @var ResourceDenormalizer */
102-
private $serializer;
50+
private ResourceDenormalizer $serializer;
10351

10452
protected function setUp(): void
10553
{
@@ -133,10 +81,10 @@ public function testSimpleResourceCanBeDenormalized(): void
13381
$dto = $this->serializer->denormalize($resource, AliasedResourceDto::class);
13482
static::assertInstanceOf(AliasedResourceDto::class, $dto);
13583

136-
static::assertSame('This is my title', $dto->getTitle());
137-
static::assertSame('This is my summary', $dto->getSummary());
138-
static::assertSame('p1', $dto->getOwnerId());
139-
static::assertSame(['t1', 't2', 't3'], $dto->getTagIds());
84+
static::assertSame('This is my title', $dto->title);
85+
static::assertSame('This is my summary', $dto->summary);
86+
static::assertSame('p1', $dto->ownerId);
87+
static::assertSame(['t1', 't2', 't3'], $dto->tagIds);
14088
}
14189

14290
public function testDenormalizationOfInvalidResourceResultsWithException(): void
@@ -218,6 +166,6 @@ public function testResourceWithAliasedOptionalToOneRelationshipCanBeDenormalize
218166
/** @var AliasedResourceDto $dto */
219167
$dto = $this->serializer->denormalize($resource, AliasedResourceDto::class);
220168
static::assertInstanceOf(AliasedResourceDto::class, $dto);
221-
static::assertNull($dto->getOwnerId());
169+
static::assertNull($dto->ownerId);
222170
}
223171
}

0 commit comments

Comments
 (0)