Completed
Push — master ( bb1b9f...121747 )
by Alexandr
05:24 queued 02:30
created

testItSetsDeprecationReasonToNullByDefault()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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