| @@ 77-107 (lines=31) @@ | ||
| 74 | $parser->parse(); |
|
| 75 | } |
|
| 76 | ||
| 77 | public function testComments() |
|
| 78 | { |
|
| 79 | $query = ' |
|
| 80 | # asdasd "asdasdasd" |
|
| 81 | # comment line 2 |
|
| 82 | ||
| 83 | query { |
|
| 84 | authors (category: "#2") { #asda asd |
|
| 85 | _id |
|
| 86 | } |
|
| 87 | } |
|
| 88 | '; |
|
| 89 | ||
| 90 | ||
| 91 | $parser = new Parser(); |
|
| 92 | ||
| 93 | $parser->setSource($query); |
|
| 94 | ||
| 95 | $this->assertEquals($parser->parse(), [ |
|
| 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 | ||
| @@ 239-268 (lines=30) @@ | ||
| 236 | $this->assertEquals($parsedStructure, $structure); |
|
| 237 | } |
|
| 238 | ||
| 239 | public function testTypedFragment() |
|
| 240 | { |
|
| 241 | $parser = new Parser(); |
|
| 242 | $parser->setSource(' |
|
| 243 | { |
|
| 244 | test: test { |
|
| 245 | name, |
|
| 246 | ... on UnionType { |
|
| 247 | unionName |
|
| 248 | } |
|
| 249 | } |
|
| 250 | } |
|
| 251 | '); |
|
| 252 | ||
| 253 | $parsedStructure = $parser->parse(); |
|
| 254 | ||
| 255 | $this->assertEquals($parsedStructure, [ |
|
| 256 | 'queries' => [ |
|
| 257 | new Query('test', 'test', [], |
|
| 258 | [ |
|
| 259 | new Field('name', null), |
|
| 260 | new TypedFragmentReference('UnionType', [ |
|
| 261 | new Field('unionName') |
|
| 262 | ]) |
|
| 263 | ]) |
|
| 264 | ], |
|
| 265 | 'mutations' => [], |
|
| 266 | 'fragments' => [] |
|
| 267 | ]); |
|
| 268 | } |
|
| 269 | ||
| 270 | public function mutationProvider() |
|
| 271 | { |
|