8
8
namespace Magento \GraphQl \CatalogUrlRewrite ;
9
9
10
10
use Magento \Catalog \Api \ProductRepositoryInterface ;
11
+ use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
12
+ use Magento \Framework \GraphQl \Query \Uid ;
11
13
use Magento \TestFramework \Helper \Bootstrap ;
12
14
use Magento \TestFramework \ObjectManager ;
13
15
use Magento \TestFramework \TestCase \GraphQlAbstract ;
@@ -22,12 +24,16 @@ class RouteTest extends GraphQlAbstract
22
24
/** @var ObjectManager */
23
25
private $ objectManager ;
24
26
27
+ /** @var Uid */
28
+ private $ idDecoder ;
29
+
25
30
/**
26
31
* {@inheritdoc}
27
32
*/
28
33
protected function setUp (): void
29
34
{
30
35
$ this ->objectManager = Bootstrap::getObjectManager ();
36
+ $ this ->idDecoder = $ this ->objectManager ->get (Uid::class);
31
37
}
32
38
33
39
/**
@@ -115,7 +121,7 @@ public function testProductUrlWithNonSeoFriendlyUrlInput()
115
121
'store_id ' => $ storeId
116
122
]
117
123
);
118
- // even of non seo friendly path requested, the seo friendly path should be preferred
124
+ // even if non seo friendly path requested, the seo friendly path should be preferred
119
125
$ relativePath = $ actualUrls ->getRequestPath ();
120
126
$ expectedType = $ actualUrls ->getEntityType ();
121
127
$ nonSeoFriendlyPath = $ actualUrls ->getTargetPath ();
@@ -481,6 +487,7 @@ public function testProductUrlResolverWithEmptyUrlSuffix()
481
487
* @param string $relativePath
482
488
* @param string $expectedType
483
489
* @param int $redirectCode
490
+ * @throws GraphQlInputException
484
491
*/
485
492
private function queryUrlAndAssertResponse (
486
493
int $ productId ,
@@ -494,14 +501,25 @@ private function queryUrlAndAssertResponse(
494
501
{
495
502
route(url:" {$ urlKey }")
496
503
{
497
- relative_url
498
- type
499
- redirect_code
500
- }
504
+ relative_url
505
+ type
506
+ redirect_code
507
+ __typename
508
+ ...on SimpleProduct {
509
+ uid
510
+ }
511
+ ...on ConfigurableProduct {
512
+ uid
513
+ }
514
+ ...on CategoryTree {
515
+ uid
516
+ }
517
+ }
501
518
}
502
519
QUERY ;
503
520
$ response = $ this ->graphQlQuery ($ query );
504
521
$ this ->assertArrayHasKey ('route ' , $ response );
522
+ $ this ->assertEquals ($ productId , $ this ->idDecoder ->decode ($ response ['route ' ]['uid ' ]));
505
523
$ this ->assertEquals ($ relativePath , $ response ['route ' ]['relative_url ' ]);
506
524
$ this ->assertEquals (strtoupper ($ expectedType ), $ response ['route ' ]['type ' ]);
507
525
$ this ->assertEquals ($ redirectCode , $ response ['route ' ]['redirect_code ' ]);
0 commit comments