@@ -240,5 +240,165 @@ enumValues(includeDeprecated: true) {
240
240
$ expectedOutput
241
241
)
242
242
);
243
+
244
+ }
245
+
246
+
247
+ /**
248
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
249
+ */
250
+ public function testDispatchIntrospectionWithDeprecatedSDL ()
251
+ {
252
+
253
+
254
+
255
+ $ query
256
+ = <<<QUERY
257
+ query IntrospectionQuery {
258
+ __schema {
259
+ queryType { name }
260
+ types {
261
+ ...FullType
262
+ }
263
+ }
264
+ }
265
+
266
+ fragment FullType on __Type {
267
+ kind
268
+ name
269
+ description
270
+ fields(includeDeprecated: true) {
271
+ name
272
+ description
273
+ args {
274
+ ...InputValue
275
+ }
276
+ type {
277
+ ...TypeRef
278
+ }
279
+ isDeprecated
280
+ deprecationReason
281
+ }
282
+ inputFields {
283
+ ...InputValue
284
+ }
285
+ interfaces {
286
+ ...TypeRef
287
+ }
288
+ enumValues(includeDeprecated: true) {
289
+ name
290
+ description
291
+ isDeprecated
292
+ deprecationReason
293
+ }
294
+ possibleTypes {
295
+ ...TypeRef
296
+ }
297
+ }
298
+
299
+ fragment InputValue on __InputValue {
300
+ name
301
+ description
302
+ type { ...TypeRef }
303
+ defaultValue
304
+ }
305
+
306
+ fragment TypeRef on __Type {
307
+ kind
308
+ name
309
+ ofType {
310
+ kind
311
+ name
312
+ ofType {
313
+ kind
314
+ name
315
+ ofType {
316
+ kind
317
+ name
318
+ ofType {
319
+ kind
320
+ name
321
+ ofType {
322
+ kind
323
+ name
324
+ ofType {
325
+ kind
326
+ name
327
+ ofType {
328
+ kind
329
+ name
330
+ }
331
+ }
332
+ }
333
+ }
334
+ }
335
+ }
336
+ }
337
+ }
338
+
339
+
340
+ QUERY ;
341
+ $ this ->objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
342
+ /** @var Cache $cache */
343
+ $ cache = $ this ->objectManager ->get (Cache::class);
344
+ $ cache ->clean ();
345
+ $ fileResolverMock = $ this ->getMockBuilder (
346
+ \Magento \Framework \Config \FileResolverInterface::class
347
+ )->disableOriginalConstructor ()->getMock ();
348
+ $ fileList = [
349
+ file_get_contents (__DIR__ . '/../_files/schemaE.graphqls ' )
350
+ ];
351
+ $ fileResolverMock ->expects ($ this ->any ())->method ('get ' )->will ($ this ->returnValue ($ fileList ));
352
+
353
+ $ postData = [
354
+ 'query ' => $ query ,
355
+ 'variables ' => null ,
356
+ 'operationName ' => 'IntrospectionQuery '
357
+ ];
358
+ /** @var Http $request */
359
+ $ request = $ this ->objectManager ->get (Http::class);
360
+ $ request ->setPathInfo ('/graphql ' );
361
+ $ request ->setMethod ('POST ' );
362
+ $ request ->setContent (json_encode ($ postData ));
363
+ $ headers = $ this ->objectManager ->create (\Zend \Http \Headers::class)
364
+ ->addHeaders (['Content-Type ' => 'application/json ' ]);
365
+ $ request ->setHeaders ($ headers );
366
+
367
+ $ response = $ this ->graphQlController ->dispatch ($ request );
368
+ $ this ->jsonSerializer ->unserialize ($ response ->getContent ());
369
+ $ expectedOutput = require __DIR__ . '/../_files/schema_response_sdl_deprecated_annotation.php ' ;
370
+
371
+
372
+ //Checks to make sure that the given description exists in the expectedOutput array
373
+
374
+ $ this ->assertTrue (
375
+ array_key_exists (
376
+ array_search (
377
+ 'Comment for SortEnum ' ,
378
+ array_column ($ expectedOutput , 'description ' )
379
+ ),
380
+ $ expectedOutput
381
+ )
382
+ );
383
+
384
+ //Checks to make sure that the given deprecatedReason exists in the expectedOutput array for enumValues, fields.
385
+ $ fieldsArray = $ expectedOutput [0 ]['fields ' ];
386
+ $ enumValuesArray = $ expectedOutput [1 ]['enumValues ' ];
387
+
388
+ foreach ($ fieldsArray as $ field ) {
389
+ if ($ field ['isDeprecated ' ] === true ) {
390
+ $ typeDeprecatedReason [] = $ field ['deprecationReason ' ];
391
+ }
392
+ }
393
+ $ this ->assertNotEmpty ($ typeDeprecatedReason );
394
+ $ this ->assertContains ('Deprecated url_path test ' , $ typeDeprecatedReason );
395
+
396
+ foreach ($ enumValuesArray as $ enumValue ) {
397
+ if ($ enumValue ['isDeprecated ' ] === true ) {
398
+ $ enumValueDeprecatedReason [] = $ enumValue ['deprecationReason ' ];
399
+ }
400
+ }
401
+ $ this ->assertNotEmpty ($ enumValueDeprecatedReason );
402
+ $ this ->assertContains ('Deprecated SortEnum Value test ' , $ enumValueDeprecatedReason );
243
403
}
244
404
}
0 commit comments