-
-
Notifications
You must be signed in to change notification settings - Fork 974
Expand file tree
/
Copy pathStringableDescriptionParameterTest.php
More file actions
88 lines (78 loc) · 2.66 KB
/
Copy pathStringableDescriptionParameterTest.php
File metadata and controls
88 lines (78 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Metadata\Tests\Resource;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Error;
use ApiPlatform\Metadata\ErrorResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\GraphQl\Mutation;
use ApiPlatform\Metadata\GraphQl\Query;
use ApiPlatform\Metadata\GraphQl\QueryCollection;
use ApiPlatform\Metadata\GraphQl\Subscription;
use ApiPlatform\Metadata\Metadata;
use ApiPlatform\Metadata\NotExposed;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use ApiPlatform\Metadata\Tests\Fixtures\Metadata\RestfulApi;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
final class StringableDescriptionParameterTest extends TestCase
{
#[DataProvider('metadataProvider')]
public function testOnMetadata(Metadata $metadata): void
{
$this->assertSame($metadata->getDescription(), 'stringable_description');
}
public static function metadataProvider(): \Generator
{
$stringableDescription = new class implements \Stringable {
public function __toString(): string
{
return 'stringable_description';
}
};
$args = [
'description' => $stringableDescription,
];
yield [new Get(...$args)];
yield [new GetCollection(...$args)];
yield [new Post(...$args)];
yield [new Put(...$args)];
yield [new Patch(...$args)];
yield [new Delete(...$args)];
yield [new Error(...$args)];
yield [new NotExposed(...$args)];
yield [new Query(...$args)];
yield [new QueryCollection(...$args)];
yield [new Mutation(...$args)];
yield [new Subscription(...$args)];
yield [new ApiResource(...$args)];
yield [new ErrorResource(...$args)];
yield [new RestfulApi(...$args)];
}
public function testOnApiProperty(): void
{
$stringableDescription = new class implements \Stringable {
public function __toString(): string
{
return 'stringable_description';
}
};
$metadata = new ApiProperty(
description: $stringableDescription,
);
$this->assertSame($metadata->getDescription(), 'stringable_description');
}
}