Completed
Pull Request — master (#172)
by Gareth
02:47
created

Issue171Test   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 101
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testItSetsDeprecationReasonToNullByDefault() 0 19 3
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
    private $introspectionQuery = <<<TEXT
9
query IntrospectionQuery {
10
                __schema {
11
                    queryType { name }
12
                    mutationType { name }
13
                    types {
14
                        ...FullType
15
                    }
16
                    directives {
17
                        name
18
                        description
19
                        args {
20
                            ...InputValue
21
                        }
22
                        onOperation
23
                        onFragment
24
                        onField
25
                    }
26
                }
27
            }
28
29
            fragment FullType on __Type {
30
                kind
31
                name
32
                description
33
                fields {
34
                    name
35
                    description
36
                    args {
37
                        ...InputValue
38
                    }
39
                    type {
40
                        ...TypeRef
41
                    }
42
                    isDeprecated
43
                    deprecationReason
44
                }
45
                inputFields {
46
                    ...InputValue
47
                }
48
                interfaces {
49
                    ...TypeRef
50
                }
51
                enumValues {
52
                    name
53
                    description
54
                    isDeprecated
55
                    deprecationReason
56
                }
57
                possibleTypes {
58
                    ...TypeRef
59
                }
60
            }
61
62
            fragment InputValue on __InputValue {
63
                name
64
                description
65
                type { ...TypeRef }
66
                defaultValue
67
            }
68
69
            fragment TypeRef on __Type {
70
                kind
71
                name
72
                ofType {
73
                    kind
74
                    name
75
                    ofType {
76
                        kind
77
                        name
78
                        ofType {
79
                            kind
80
                            name
81
                        }
82
                    }
83
                }
84
            }
85
TEXT;
86
87
    public function testItSetsDeprecationReasonToNullByDefault()
88
    {
89
        $schema = new Issue171Schema();
90
        $processor = new Processor($schema);
91
92
        $processor->processPayload($this->introspectionQuery, []);
93
        $resp = $processor->getResponseData();
94
95
        $enumTypes = array_filter($resp['data']['__schema']['types'], function($type){
96
            return ($type['kind'] === 'ENUM');
97
        });
98
99
        foreach ($enumTypes as $enumType) {
100
            foreach ($enumType['enumValues'] as $value) {
101
                $this->assertFalse($value['isDeprecated']);
102
                $this->assertNull($value['deprecationReason'], "deprecationReason should have been null");
103
            }
104
        }
105
    }
106
}