@@ -357,7 +357,7 @@ public function testFindOneByDataWithRequestPathIsRedirect()
357
357
358
358
$ urlRewriteRowInDb = [
359
359
UrlRewrite::REQUEST_PATH => $ origRequestPath . '/ ' ,
360
- UrlRewrite::TARGET_PATH => 'page-A/ ' ,
360
+ UrlRewrite::TARGET_PATH => 'page-A/ ' ,
361
361
UrlRewrite::REDIRECT_TYPE => 301 ,
362
362
UrlRewrite::STORE_ID => 1 ,
363
363
];
@@ -379,6 +379,65 @@ public function testFindOneByDataWithRequestPathIsRedirect()
379
379
$ this ->assertEquals (['urlRewrite1 ' ], $ this ->storage ->findOneByData ($ data ));
380
380
}
381
381
382
+ public function testFindOneByDataWithRequestPathTwoResults ()
383
+ {
384
+ $ origRequestPath = 'page-one ' ;
385
+ $ data = [
386
+ 'col1 ' => 'val1 ' ,
387
+ 'col2 ' => 'val2 ' ,
388
+ UrlRewrite::REQUEST_PATH => $ origRequestPath ,
389
+ ];
390
+
391
+ $ this ->select ->expects ($ this ->at (1 ))
392
+ ->method ('where ' )
393
+ ->with ('col1 IN (?) ' , 'val1 ' );
394
+
395
+ $ this ->select ->expects ($ this ->at (2 ))
396
+ ->method ('where ' )
397
+ ->with ('col2 IN (?) ' , 'val2 ' );
398
+
399
+ $ this ->select ->expects ($ this ->at (3 ))
400
+ ->method ('where ' )
401
+ ->with ('request_path IN (?) ' , [$ origRequestPath , $ origRequestPath . '/ ' ]);
402
+
403
+ $ this ->connectionMock ->expects ($ this ->any ())
404
+ ->method ('quoteIdentifier ' )
405
+ ->will ($ this ->returnArgument (0 ));
406
+
407
+ $ this ->connectionMock ->expects ($ this ->never ())
408
+ ->method ('fetchRow ' );
409
+
410
+ $ urlRewriteRowInDb = [
411
+ UrlRewrite::REQUEST_PATH => $ origRequestPath . '/ ' ,
412
+ UrlRewrite::TARGET_PATH => 'page-A/ ' ,
413
+ UrlRewrite::REDIRECT_TYPE => 301 ,
414
+ UrlRewrite::STORE_ID => 1 ,
415
+ ];
416
+
417
+ $ urlRewriteRowInDb2 = [
418
+ UrlRewrite::REQUEST_PATH => $ origRequestPath ,
419
+ UrlRewrite::TARGET_PATH => 'page-B/ ' ,
420
+ UrlRewrite::REDIRECT_TYPE => 301 ,
421
+ UrlRewrite::STORE_ID => 1 ,
422
+ ];
423
+
424
+ $ this ->connectionMock ->expects ($ this ->once ())
425
+ ->method ('fetchAll ' )
426
+ ->with ($ this ->select )
427
+ ->will ($ this ->returnValue ([$ urlRewriteRowInDb , $ urlRewriteRowInDb2 ]));
428
+
429
+ $ this ->dataObjectHelper ->expects ($ this ->at (0 ))
430
+ ->method ('populateWithArray ' )
431
+ ->with (['urlRewrite1 ' ], $ urlRewriteRowInDb2 , \Magento \UrlRewrite \Service \V1 \Data \UrlRewrite::class)
432
+ ->will ($ this ->returnSelf ());
433
+
434
+ $ this ->urlRewriteFactory ->expects ($ this ->at (0 ))
435
+ ->method ('create ' )
436
+ ->will ($ this ->returnValue (['urlRewrite1 ' ]));
437
+
438
+ $ this ->assertEquals (['urlRewrite1 ' ], $ this ->storage ->findOneByData ($ data ));
439
+ }
440
+
382
441
public function testReplace ()
383
442
{
384
443
$ urlFirst = $ this ->getMock (\Magento \UrlRewrite \Service \V1 \Data \UrlRewrite::class, [], [], '' , false );
0 commit comments