@@ -471,75 +471,81 @@ public function testItem404(string $uri): void
471471 $ this ->assertResponseStatusCodeSame (404 );
472472 }
473473
474- // public static function providerEnumItemsGraphQl(): iterable
475- // {
476- // // Integer cases
477- // $query = <<<'GRAPHQL'
478- // query GetAvailability($identifier: ID!) {
479- // availability(id: $identifier) {
480- // value
481- // }
482- // }
483- // GRAPHQL;
484- // foreach (Availability::cases() as $case) {
485- // yield [$query, ['identifier' => '/availabilities/'.$case->value], ['data' => ['availability' => ['value' => $case->value]]]];
486- // }
487- //
488- // // String cases
489- // $query = <<<'GRAPHQL'
490- // query GetAvailabilityStatus($identifier: ID!) {
491- // availabilityStatus(id: $identifier) {
492- // value
493- // }
494- // }
495- // GRAPHQL;
496- // foreach (AvailabilityStatus::cases() as $case) {
497- // yield [$query, ['identifier' => '/availability_statuses/'.$case->value], ['data' => ['availability_status' => ['value' => $case->value]]]];
498- // }
499- // }
500- //
501- // /**
502- // * @dataProvider providerEnumItemsGraphQl
503- // *
504- // * @group legacy
505- // */
506- // public function testItemGraphql(string $query, array $variables, array $expected): void
507- // {
508- // $options = (new HttpOptions())
509- // ->setJson(['query' => $query, 'variables' => $variables])
510- // ->setHeaders(['Content-Type' => 'application/json']);
511- // self::createClient()->request('POST', '/graphql', $options->toArray());
512- //
513- // $this->assertResponseIsSuccessful();
514- // $this->assertJsonEquals($expected);
515- // }
516- //
517- // public function testCollectionGraphQl(): void
518- // {
519- // $query = <<<'GRAPHQL'
520- // query {
521- // backedEnumIntegerResources {
522- // value
523- // }
524- // }
525- // GRAPHQL;
526- // $options = (new HttpOptions())
527- // ->setJson(['query' => $query, 'variables' => []])
528- // ->setHeaders(['Content-Type' => 'application/json']);
529- // self::createClient()->request('POST', '/graphql', $options->toArray());
530- //
531- // $this->assertResponseIsSuccessful();
532- // $this->assertJsonEquals([
533- // 'data' => [
534- // 'backedEnumIntegerResources' => [
535- // ['value' => 1],
536- // ['value' => 2],
537- // ['value' => 3],
538- // ],
539- // ],
540- // ]);
541- // }
474+ public static function providerEnumItemsGraphQl (): iterable
475+ {
476+ // Integer cases
477+ $ query = <<<'GRAPHQL'
478+ query GetAvailability($identifier: ID!) {
479+ availability(id: $identifier) {
480+ value
481+ }
482+ }
483+ GRAPHQL;
484+ foreach (Availability::cases () as $ case ) {
485+ yield [$ query , ['identifier ' => '/availabilities/ ' .$ case ->value ], ['data ' => ['availability ' => ['value ' => $ case ->value ]]]];
486+ }
487+
488+ // String cases
489+ $ query = <<<'GRAPHQL'
490+ query GetAvailabilityStatus($identifier: ID!) {
491+ availabilityStatus(id: $identifier) {
492+ value
493+ }
494+ }
495+ GRAPHQL;
496+ foreach (AvailabilityStatus::cases () as $ case ) {
497+ yield [$ query , ['identifier ' => '/availability_statuses/ ' .$ case ->value ], ['data ' => ['availabilityStatus ' => ['value ' => $ case ->value ]]]];
498+ }
499+ }
500+
501+ /**
502+ * @dataProvider providerEnumItemsGraphQl
503+ *
504+ * @group legacy
505+ */
506+ public function testItemGraphql (string $ query , array $ variables , array $ expected ): void
507+ {
508+ $ options = (new HttpOptions ())
509+ ->setJson (['query ' => $ query , 'variables ' => $ variables ])
510+ ->setHeaders (['Content-Type ' => 'application/json ' ]);
511+ self ::createClient ()->request ('POST ' , '/graphql ' , $ options ->toArray ());
512+
513+ $ this ->assertResponseIsSuccessful ();
514+ $ this ->assertJsonEquals ($ expected );
515+ }
542516
517+ /**
518+ * @group legacy
519+ */
520+ public function testCollectionGraphQl (): void
521+ {
522+ $ query = <<<'GRAPHQL'
523+ query {
524+ backedEnumIntegerResources {
525+ value
526+ }
527+ }
528+ GRAPHQL;
529+ $ options = (new HttpOptions ())
530+ ->setJson (['query ' => $ query , 'variables ' => []])
531+ ->setHeaders (['Content-Type ' => 'application/json ' ]);
532+ self ::createClient ()->request ('POST ' , '/graphql ' , $ options ->toArray ());
533+
534+ $ this ->assertResponseIsSuccessful ();
535+ $ this ->assertJsonEquals ([
536+ 'data ' => [
537+ 'backedEnumIntegerResources ' => [
538+ ['value ' => 1 ],
539+ ['value ' => 2 ],
540+ ['value ' => 3 ],
541+ ],
542+ ],
543+ ]);
544+ }
545+
546+ /**
547+ * @group legacy
548+ */
543549 public function testItemGraphQlInteger (): void
544550 {
545551 $ query = <<<'GRAPHQL'
@@ -559,7 +565,9 @@ public function testItemGraphQlInteger(): void
559565 $ this ->assertResponseIsSuccessful ();
560566 $ this ->assertJsonEquals ([
561567 'data ' => [
562- 'status ' => [
568+ 'backedEnumIntegerResource ' => [
569+ 'description ' => 'We say yes ' ,
570+ 'name ' => 'Yes ' ,
563571 'value ' => 1 ,
564572 ],
565573 ],
0 commit comments