| @@ 79-108 (lines=30) @@ | ||
| 76 | }'); |
|
| 77 | } |
|
| 78 | ||
| 79 | public function testComments() |
|
| 80 | { |
|
| 81 | $query = ' |
|
| 82 | # asdasd "asdasdasd" |
|
| 83 | # comment line 2 |
|
| 84 | ||
| 85 | query { |
|
| 86 | authors (category: "#2") { #asda asd |
|
| 87 | _id |
|
| 88 | } |
|
| 89 | } |
|
| 90 | '; |
|
| 91 | ||
| 92 | ||
| 93 | $parser = new Parser(); |
|
| 94 | ||
| 95 | $this->assertEquals($parser->parse($query), [ |
|
| 96 | 'queries' => [ |
|
| 97 | new Query('authors', null, |
|
| 98 | [ |
|
| 99 | new Argument('category', new Literal('#2')) |
|
| 100 | ], |
|
| 101 | [ |
|
| 102 | new Field('_id', null), |
|
| 103 | ]) |
|
| 104 | ], |
|
| 105 | 'mutations' => [], |
|
| 106 | 'fragments' => [] |
|
| 107 | ]); |
|
| 108 | } |
|
| 109 | ||
| 110 | ||
| 111 | /** |
|
| @@ 137-151 (lines=15) @@ | ||
| 134 | ], $data); |
|
| 135 | } |
|
| 136 | ||
| 137 | public function testQueryWithFields() |
|
| 138 | { |
|
| 139 | $parser = new Parser(); |
|
| 140 | $data = $parser->parse('{ post, user { name } }'); |
|
| 141 | $this->assertEquals([ |
|
| 142 | 'queries' => [ |
|
| 143 | new Query('post'), |
|
| 144 | new Query('user', null, [], [ |
|
| 145 | new Field('name') |
|
| 146 | ]) |
|
| 147 | ], |
|
| 148 | 'mutations' => [], |
|
| 149 | 'fragments' => [], |
|
| 150 | ], $data); |
|
| 151 | } |
|
| 152 | ||
| 153 | public function testFragmentWithFields() |
|
| 154 | { |
|
| @@ 153-175 (lines=23) @@ | ||
| 150 | ], $data); |
|
| 151 | } |
|
| 152 | ||
| 153 | public function testFragmentWithFields() |
|
| 154 | { |
|
| 155 | $parser = new Parser(); |
|
| 156 | $data = $parser->parse(' |
|
| 157 | fragment FullType on __Type { |
|
| 158 | kind |
|
| 159 | fields { |
|
| 160 | name |
|
| 161 | } |
|
| 162 | }'); |
|
| 163 | $this->assertEquals([ |
|
| 164 | 'queries' => [], |
|
| 165 | 'mutations' => [], |
|
| 166 | 'fragments' => [ |
|
| 167 | new Fragment('FullType', '__Type', [ |
|
| 168 | new Field('kind'), |
|
| 169 | new Query('fields', null, [], [ |
|
| 170 | new Field('name') |
|
| 171 | ]) |
|
| 172 | ]) |
|
| 173 | ], |
|
| 174 | ], $data); |
|
| 175 | } |
|
| 176 | ||
| 177 | public function testInspectionQuery() |
|
| 178 | { |
|
| @@ 377-404 (lines=28) @@ | ||
| 374 | $this->assertEquals($parsedStructure, $structure); |
|
| 375 | } |
|
| 376 | ||
| 377 | public function testTypedFragment() |
|
| 378 | { |
|
| 379 | $parser = new Parser(); |
|
| 380 | $parsedStructure = $parser->parse(' |
|
| 381 | { |
|
| 382 | test: test { |
|
| 383 | name, |
|
| 384 | ... on UnionType { |
|
| 385 | unionName |
|
| 386 | } |
|
| 387 | } |
|
| 388 | } |
|
| 389 | '); |
|
| 390 | ||
| 391 | $this->assertEquals($parsedStructure, [ |
|
| 392 | 'queries' => [ |
|
| 393 | new Query('test', 'test', [], |
|
| 394 | [ |
|
| 395 | new Field('name', null), |
|
| 396 | new TypedFragmentReference('UnionType', [ |
|
| 397 | new Field('unionName') |
|
| 398 | ]) |
|
| 399 | ]) |
|
| 400 | ], |
|
| 401 | 'mutations' => [], |
|
| 402 | 'fragments' => [] |
|
| 403 | ]); |
|
| 404 | } |
|
| 405 | ||
| 406 | public function mutationProvider() |
|
| 407 | { |
|