1 | <?php |
||
6 | * Copyright (c) 2018 Ashley Hutson <https://github.com/asheliahut>. |
||
7 | * Copyright (c) 2015–2018 Contributors. |
||
8 | * |
||
9 | * http://opensource.org/licenses/MIT |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace Youshido\Tests\Issues\Issue171; |
||
15 | |||
16 | use Youshido\GraphQL\Execution\Processor; |
||
17 | |||
18 | class Issue171Test extends \PHPUnit_Framework_TestCase |
||
19 | { |
||
20 | public function testItSetsDeprecationReasonToNullByDefault(): void |
||
21 | { |
||
22 | $schema = new Issue171Schema(); |
||
23 | $processor = new Processor($schema); |
||
24 | |||
25 | $processor->processPayload($this->getIntrospectionQuery(), []); |
||
26 | $resp = $processor->getResponseData(); |
||
27 | |||
28 | $enumTypes = \array_filter($resp['data']['__schema']['types'], static function ($type) { |
||
29 | return 'ENUM' === $type['kind']; |
||
30 | }); |
||
31 | |||
32 | foreach ($enumTypes as $enumType) { |
||
33 | foreach ($enumType['enumValues'] as $value) { |
||
34 | $this->assertFalse($value['isDeprecated']); |
||
35 | $this->assertNull($value['deprecationReason'], 'deprecationReason should have been null'); |
||
36 | } |
||
37 | } |
||
38 | } |
||
39 | |||
40 | private function getIntrospectionQuery() |
||
41 | { |
||
42 | return <<<'TEXT' |
||
43 | query IntrospectionQuery { |
||
44 | __schema { |
||
45 | queryType { name } |
||
46 | mutationType { name } |
||
47 | types { |
||
48 | ...FullType |
||
49 | } |
||
50 | directives { |
||
51 | name |
||
52 | description |
||
53 | args { |
||
54 | ...InputValue |
||
55 | } |
||
56 | onOperation |
||
57 | onFragment |
||
58 | onField |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 | |||
63 | fragment FullType on __Type { |
||
64 | kind |
||
65 | name |
||
66 | description |
||
67 | fields { |
||
68 | name |
||
69 | description |
||
70 | args { |
||
71 | ...InputValue |
||
72 | } |
||
73 | type { |
||
74 | ...TypeRef |
||
75 | } |
||
76 | isDeprecated |
||
77 | deprecationReason |
||
78 | } |
||
79 | inputFields { |
||
80 | ...InputValue |
||
81 | } |
||
82 | interfaces { |
||
83 | ...TypeRef |
||
84 | } |
||
85 | enumValues { |
||
86 | name |
||
87 | description |
||
88 | isDeprecated |
||
89 | deprecationReason |
||
90 | } |
||
91 | possibleTypes { |
||
92 | ...TypeRef |
||
93 | } |
||
94 | } |
||
95 | |||
96 | fragment InputValue on __InputValue { |
||
97 | name |
||
98 | description |
||
99 | type { ...TypeRef } |
||
100 | defaultValue |
||
101 | } |
||
102 | |||
103 | fragment TypeRef on __Type { |
||
104 | kind |
||
105 | name |
||
106 | ofType { |
||
107 | kind |
||
108 | name |
||
109 | ofType { |
||
110 | kind |
||
122 |