@@ -67,12 +67,14 @@ public function testProductUrlResolver()
67
67
);
68
68
$ relativePath = $ actualUrls ->getRequestPath ();
69
69
$ expectedType = $ actualUrls ->getEntityType ();
70
+ $ redirectCode = $ actualUrls ->getRedirectType ();
70
71
71
72
$ this ->queryUrlAndAssertResponse (
72
73
(int ) $ product ->getEntityId (),
73
74
$ urlPath ,
74
75
$ relativePath ,
75
- $ expectedType
76
+ $ expectedType ,
77
+ $ redirectCode
76
78
);
77
79
}
78
80
@@ -116,12 +118,14 @@ public function testProductUrlWithNonSeoFriendlyUrlInput()
116
118
$ relativePath = $ actualUrls ->getRequestPath ();
117
119
$ expectedType = $ actualUrls ->getEntityType ();
118
120
$ nonSeoFriendlyPath = $ actualUrls ->getTargetPath ();
121
+ $ redirectCode = $ actualUrls ->getRedirectType ();
119
122
120
123
$ this ->queryUrlAndAssertResponse (
121
124
(int ) $ product ->getEntityId (),
122
125
$ nonSeoFriendlyPath ,
123
126
$ relativePath ,
124
- $ expectedType
127
+ $ expectedType ,
128
+ $ redirectCode
125
129
);
126
130
}
127
131
@@ -172,15 +176,17 @@ public function testRedirectsAndCustomInput()
172
176
(int ) $ product ->getEntityId (),
173
177
$ renamedKey . $ suffix ,
174
178
$ actualUrls ->getRequestPath (),
175
- $ actualUrls ->getEntityType ()
179
+ $ actualUrls ->getEntityType (),
180
+ 0
176
181
);
177
182
178
183
// querying a url that's a redirect the active redirected final url
179
184
$ this ->queryUrlAndAssertResponse (
180
185
(int ) $ product ->getEntityId (),
181
186
$ productSku . $ suffix ,
182
187
$ actualUrls ->getRequestPath (),
183
- $ actualUrls ->getEntityType ()
188
+ $ actualUrls ->getEntityType (),
189
+ 301
184
190
);
185
191
186
192
// create custom url that doesn't redirect
@@ -209,7 +215,8 @@ public function testRedirectsAndCustomInput()
209
215
(int ) $ product ->getEntityId (),
210
216
$ customUrl ,
211
217
$ customUrl ,
212
- $ actualUrls ->getEntityType ()
218
+ $ actualUrls ->getEntityType (),
219
+ 0
213
220
);
214
221
215
222
// change custom url that does redirect
@@ -224,7 +231,8 @@ public function testRedirectsAndCustomInput()
224
231
(int ) $ product ->getEntityId (),
225
232
$ customUrl ,
226
233
$ actualUrls ->getRequestPath (),
227
- strtoupper ($ actualUrls ->getEntityType ())
234
+ strtoupper ($ actualUrls ->getEntityType ()),
235
+ 301
228
236
);
229
237
$ urlRewriteModel ->delete ();
230
238
}
@@ -271,7 +279,8 @@ public function testCategoryUrlResolver()
271
279
(int ) $ categoryId ,
272
280
$ urlPath ,
273
281
$ relativePath ,
274
- $ expectedType
282
+ $ expectedType ,
283
+ 0
275
284
);
276
285
}
277
286
@@ -321,7 +330,8 @@ public function testProductUrlRewriteResolver()
321
330
(int ) $ product ->getEntityId (),
322
331
$ urlPath ,
323
332
$ relativePath ,
324
- $ expectedType
333
+ $ expectedType ,
334
+ 0
325
335
);
326
336
}
327
337
@@ -355,6 +365,7 @@ public function testInvalidUrlResolverInput()
355
365
id
356
366
relative_url
357
367
type
368
+ redirectCode
358
369
}
359
370
}
360
371
QUERY ;
@@ -400,12 +411,13 @@ public function testCategoryUrlWithLeadingSlash()
400
411
QUERY ;
401
412
$ response = $ this ->graphQlQuery ($ query );
402
413
$ urlPath = $ response ['category ' ]['url_key ' ] . $ response ['category ' ]['url_suffix ' ];
403
-
414
+ $ urlPathWithLeadingSlash = " / { $ urlPath }" ;
404
415
$ this ->queryUrlAndAssertResponse (
405
416
(int ) $ categoryId ,
406
- $ urlPath ,
417
+ $ urlPathWithLeadingSlash ,
407
418
$ relativePath ,
408
- $ expectedType
419
+ $ expectedType ,
420
+ 0
409
421
);
410
422
}
411
423
@@ -438,13 +450,15 @@ public function testGetNonExistentUrlRewrite()
438
450
id
439
451
relative_url
440
452
type
453
+ redirectCode
441
454
}
442
455
}
443
456
QUERY ;
444
457
$ response = $ this ->graphQlQuery ($ query );
445
458
$ this ->assertArrayHasKey ('urlResolver ' , $ response );
446
459
$ this ->assertEquals ('PRODUCT ' , $ response ['urlResolver ' ]['type ' ]);
447
460
$ this ->assertEquals ($ relativePath , $ response ['urlResolver ' ]['relative_url ' ]);
461
+ $ this ->assertEquals (0 , $ response ['urlResolver ' ]['redirectCode ' ]);
448
462
}
449
463
450
464
/**
@@ -454,12 +468,14 @@ public function testGetNonExistentUrlRewrite()
454
468
* @param string $urlKey
455
469
* @param string $relativePath
456
470
* @param string $expectedType
471
+ * @param int $redirectCode
457
472
*/
458
473
private function queryUrlAndAssertResponse (
459
474
int $ productId ,
460
475
string $ urlKey ,
461
476
string $ relativePath ,
462
- string $ expectedType
477
+ string $ expectedType ,
478
+ int $ redirectCode
463
479
): void {
464
480
$ query
465
481
= <<<QUERY
@@ -469,6 +485,7 @@ private function queryUrlAndAssertResponse(
469
485
id
470
486
relative_url
471
487
type
488
+ redirectCode
472
489
}
473
490
}
474
491
QUERY ;
@@ -477,5 +494,6 @@ private function queryUrlAndAssertResponse(
477
494
$ this ->assertEquals ($ productId , $ response ['urlResolver ' ]['id ' ]);
478
495
$ this ->assertEquals ($ relativePath , $ response ['urlResolver ' ]['relative_url ' ]);
479
496
$ this ->assertEquals (strtoupper ($ expectedType ), $ response ['urlResolver ' ]['type ' ]);
497
+ $ this ->assertEquals ($ redirectCode , $ response ['urlResolver ' ]['redirectCode ' ]);
480
498
}
481
499
}
0 commit comments