Completed
Pull Request — master (#204)
by Ryan
11:34
created

Issue171Test   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 104
rs 10
c 2
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2015–2018 Alexandr Viniychuk <http://youshido.com>.
4
 * Copyright (c) 2015–2018 Portey Vasil <https://github.com/portey>.
5
 * Copyright (c) 2018 Ryan Parman <https://github.com/skyzyx>.
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
111
                        name
112
                        ofType {
113
                            kind
114
                            name
115
                        }
116
                    }
117
                }
118
            }
119
TEXT;
120
    }
121
}
122