88namespace Magento \GraphQl \CatalogUrlRewrite ;
99
1010use Magento \Catalog \Api \ProductRepositoryInterface ;
11+ use Magento \Framework \GraphQl \Exception \GraphQlInputException ;
12+ use Magento \Framework \GraphQl \Query \Uid ;
1113use Magento \TestFramework \Helper \Bootstrap ;
1214use Magento \TestFramework \ObjectManager ;
1315use Magento \TestFramework \TestCase \GraphQlAbstract ;
@@ -22,12 +24,16 @@ class RouteTest extends GraphQlAbstract
2224 /** @var ObjectManager */
2325 private $ objectManager ;
2426
27+ /** @var Uid */
28+ private $ idDecoder ;
29+
2530 /**
2631 * {@inheritdoc}
2732 */
2833 protected function setUp (): void
2934 {
3035 $ this ->objectManager = Bootstrap::getObjectManager ();
36+ $ this ->idDecoder = $ this ->objectManager ->get (Uid::class);
3137 }
3238
3339 /**
@@ -115,7 +121,7 @@ public function testProductUrlWithNonSeoFriendlyUrlInput()
115121 'store_id ' => $ storeId
116122 ]
117123 );
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
119125 $ relativePath = $ actualUrls ->getRequestPath ();
120126 $ expectedType = $ actualUrls ->getEntityType ();
121127 $ nonSeoFriendlyPath = $ actualUrls ->getTargetPath ();
@@ -481,6 +487,7 @@ public function testProductUrlResolverWithEmptyUrlSuffix()
481487 * @param string $relativePath
482488 * @param string $expectedType
483489 * @param int $redirectCode
490+ * @throws GraphQlInputException
484491 */
485492 private function queryUrlAndAssertResponse (
486493 int $ productId ,
@@ -494,14 +501,25 @@ private function queryUrlAndAssertResponse(
494501{
495502 route(url:" {$ urlKey }")
496503 {
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+ }
501518}
502519QUERY ;
503520 $ response = $ this ->graphQlQuery ($ query );
504521 $ this ->assertArrayHasKey ('route ' , $ response );
522+ $ this ->assertEquals ($ productId , $ this ->idDecoder ->decode ($ response ['route ' ]['uid ' ]));
505523 $ this ->assertEquals ($ relativePath , $ response ['route ' ]['relative_url ' ]);
506524 $ this ->assertEquals (strtoupper ($ expectedType ), $ response ['route ' ]['type ' ]);
507525 $ this ->assertEquals ($ redirectCode , $ response ['route ' ]['redirect_code ' ]);
0 commit comments