@@ -67,12 +67,14 @@ public function testProductUrlResolver()
6767 );
6868 $ relativePath = $ actualUrls ->getRequestPath ();
6969 $ expectedType = $ actualUrls ->getEntityType ();
70+ $ redirectCode = $ actualUrls ->getRedirectType ();
7071
7172 $ this ->queryUrlAndAssertResponse (
7273 (int ) $ product ->getEntityId (),
7374 $ urlPath ,
7475 $ relativePath ,
75- $ expectedType
76+ $ expectedType ,
77+ $ redirectCode
7678 );
7779 }
7880
@@ -116,12 +118,14 @@ public function testProductUrlWithNonSeoFriendlyUrlInput()
116118 $ relativePath = $ actualUrls ->getRequestPath ();
117119 $ expectedType = $ actualUrls ->getEntityType ();
118120 $ nonSeoFriendlyPath = $ actualUrls ->getTargetPath ();
121+ $ redirectCode = $ actualUrls ->getRedirectType ();
119122
120123 $ this ->queryUrlAndAssertResponse (
121124 (int ) $ product ->getEntityId (),
122125 $ nonSeoFriendlyPath ,
123126 $ relativePath ,
124- $ expectedType
127+ $ expectedType ,
128+ $ redirectCode
125129 );
126130 }
127131
@@ -172,15 +176,17 @@ public function testRedirectsAndCustomInput()
172176 (int ) $ product ->getEntityId (),
173177 $ renamedKey . $ suffix ,
174178 $ actualUrls ->getRequestPath (),
175- $ actualUrls ->getEntityType ()
179+ $ actualUrls ->getEntityType (),
180+ 0
176181 );
177182
178183 // querying a url that's a redirect the active redirected final url
179184 $ this ->queryUrlAndAssertResponse (
180185 (int ) $ product ->getEntityId (),
181186 $ productSku . $ suffix ,
182187 $ actualUrls ->getRequestPath (),
183- $ actualUrls ->getEntityType ()
188+ $ actualUrls ->getEntityType (),
189+ 301
184190 );
185191
186192 // create custom url that doesn't redirect
@@ -209,7 +215,8 @@ public function testRedirectsAndCustomInput()
209215 (int ) $ product ->getEntityId (),
210216 $ customUrl ,
211217 $ customUrl ,
212- $ actualUrls ->getEntityType ()
218+ $ actualUrls ->getEntityType (),
219+ 0
213220 );
214221
215222 // change custom url that does redirect
@@ -224,7 +231,8 @@ public function testRedirectsAndCustomInput()
224231 (int ) $ product ->getEntityId (),
225232 $ customUrl ,
226233 $ actualUrls ->getRequestPath (),
227- strtoupper ($ actualUrls ->getEntityType ())
234+ strtoupper ($ actualUrls ->getEntityType ()),
235+ 301
228236 );
229237 $ urlRewriteModel ->delete ();
230238 }
@@ -271,7 +279,8 @@ public function testCategoryUrlResolver()
271279 (int ) $ categoryId ,
272280 $ urlPath ,
273281 $ relativePath ,
274- $ expectedType
282+ $ expectedType ,
283+ 0
275284 );
276285 }
277286
@@ -321,7 +330,8 @@ public function testProductUrlRewriteResolver()
321330 (int ) $ product ->getEntityId (),
322331 $ urlPath ,
323332 $ relativePath ,
324- $ expectedType
333+ $ expectedType ,
334+ 0
325335 );
326336 }
327337
@@ -355,6 +365,7 @@ public function testInvalidUrlResolverInput()
355365 id
356366 relative_url
357367 type
368+ redirectCode
358369 }
359370}
360371QUERY ;
@@ -400,12 +411,13 @@ public function testCategoryUrlWithLeadingSlash()
400411QUERY ;
401412 $ response = $ this ->graphQlQuery ($ query );
402413 $ urlPath = $ response ['category ' ]['url_key ' ] . $ response ['category ' ]['url_suffix ' ];
403-
414+ $ urlPathWithLeadingSlash = " / { $ urlPath }" ;
404415 $ this ->queryUrlAndAssertResponse (
405416 (int ) $ categoryId ,
406- $ urlPath ,
417+ $ urlPathWithLeadingSlash ,
407418 $ relativePath ,
408- $ expectedType
419+ $ expectedType ,
420+ 0
409421 );
410422 }
411423
@@ -438,13 +450,15 @@ public function testGetNonExistentUrlRewrite()
438450 id
439451 relative_url
440452 type
453+ redirectCode
441454 }
442455}
443456QUERY ;
444457 $ response = $ this ->graphQlQuery ($ query );
445458 $ this ->assertArrayHasKey ('urlResolver ' , $ response );
446459 $ this ->assertEquals ('PRODUCT ' , $ response ['urlResolver ' ]['type ' ]);
447460 $ this ->assertEquals ($ relativePath , $ response ['urlResolver ' ]['relative_url ' ]);
461+ $ this ->assertEquals (0 , $ response ['urlResolver ' ]['redirectCode ' ]);
448462 }
449463
450464 /**
@@ -454,12 +468,14 @@ public function testGetNonExistentUrlRewrite()
454468 * @param string $urlKey
455469 * @param string $relativePath
456470 * @param string $expectedType
471+ * @param int $redirectCode
457472 */
458473 private function queryUrlAndAssertResponse (
459474 int $ productId ,
460475 string $ urlKey ,
461476 string $ relativePath ,
462- string $ expectedType
477+ string $ expectedType ,
478+ int $ redirectCode
463479 ): void {
464480 $ query
465481 = <<<QUERY
@@ -469,6 +485,7 @@ private function queryUrlAndAssertResponse(
469485 id
470486 relative_url
471487 type
488+ redirectCode
472489 }
473490}
474491QUERY ;
@@ -477,5 +494,6 @@ private function queryUrlAndAssertResponse(
477494 $ this ->assertEquals ($ productId , $ response ['urlResolver ' ]['id ' ]);
478495 $ this ->assertEquals ($ relativePath , $ response ['urlResolver ' ]['relative_url ' ]);
479496 $ this ->assertEquals (strtoupper ($ expectedType ), $ response ['urlResolver ' ]['type ' ]);
497+ $ this ->assertEquals ($ redirectCode , $ response ['urlResolver ' ]['redirectCode ' ]);
480498 }
481499}
0 commit comments