Code Duplication    Length = 18-33 lines in 4 locations

Tests/Parser/ParserTest.php 4 locations

@@ 59-91 (lines=33) @@
56
        ');
57
    }
58
59
    public function testComments()
60
    {
61
        $query = '
62
            # asdasd "asdasdasd"
63
            # comment line 2
64
65
            query {
66
              authors (category: "#2") { #asda asd
67
                _id
68
              }
69
            }
70
        ';
71
72
73
        $parser = new Parser();
74
75
        $this->assertEquals($parser->parse($query), [
76
            'queries'            => [
77
                new Query('authors', null,
78
                    [
79
                        new Argument('category', new Literal('#2'))
80
                    ],
81
                    [
82
                        new Field('_id', null),
83
                    ])
84
            ],
85
            'mutations'          => [],
86
            'fragments'          => [],
87
            'fragmentReferences' => [],
88
            'variables'          => [],
89
            'variableReferences' => []
90
        ]);
91
    }
92
93
94
    /**
@@ 123-140 (lines=18) @@
120
        ], $data);
121
    }
122
123
    public function testQueryWithFields()
124
    {
125
        $parser = new Parser();
126
        $data   = $parser->parse('{ post, user { name } }');
127
        $this->assertEquals([
128
            'queries'            => [
129
                new Query('post'),
130
                new Query('user', null, [], [
131
                    new Field('name')
132
                ])
133
            ],
134
            'mutations'          => [],
135
            'fragments'          => [],
136
            'fragmentReferences' => [],
137
            'variables'          => [],
138
            'variableReferences' => [],
139
        ], $data);
140
    }
141
142
    public function testFragmentWithFields()
143
    {
@@ 142-167 (lines=26) @@
139
        ], $data);
140
    }
141
142
    public function testFragmentWithFields()
143
    {
144
        $parser = new Parser();
145
        $data   = $parser->parse('
146
            fragment FullType on __Type {
147
                kind
148
                fields {
149
                    name
150
                }
151
            }');
152
        $this->assertEquals([
153
            'queries'            => [],
154
            'mutations'          => [],
155
            'fragments'          => [
156
                new Fragment('FullType', '__Type', [
157
                    new Field('kind'),
158
                    new Query('fields', null, [], [
159
                        new Field('name')
160
                    ])
161
                ])
162
            ],
163
            'fragmentReferences' => [],
164
            'variables'          => [],
165
            'variableReferences' => [],
166
        ], $data);
167
    }
168
169
    public function testInspectionQuery()
170
    {
@@ 381-411 (lines=31) @@
378
        $this->assertEquals($parsedStructure, $structure);
379
    }
380
381
    public function testTypedFragment()
382
    {
383
        $parser          = new Parser();
384
        $parsedStructure = $parser->parse('
385
            {
386
                test: test {
387
                    name,
388
                    ... on UnionType {
389
                        unionName
390
                    }
391
                }
392
            }
393
        ');
394
395
        $this->assertEquals($parsedStructure, [
396
            'queries'            => [
397
                new Query('test', 'test', [],
398
                    [
399
                        new Field('name', null),
400
                        new TypedFragmentReference('UnionType', [
401
                            new Field('unionName')
402
                        ])
403
                    ])
404
            ],
405
            'mutations'          => [],
406
            'fragments'          => [],
407
            'fragmentReferences' => [],
408
            'variables'          => [],
409
            'variableReferences' => []
410
        ]);
411
    }
412
413
    public function mutationProvider()
414
    {