@@ -683,7 +683,7 @@ public function testClearProductUrls()
683
683
/**
684
684
* Cover canonicalUrlRewriteGenerate().
685
685
*/
686
- public function testCanonicalUrlRewriteGenerate ()
686
+ public function testCanonicalUrlRewriteGenerateWithUrlPath ()
687
687
{
688
688
$ productId = 'product_id ' ;
689
689
$ requestPath = 'simple-product.html ' ;
@@ -704,6 +704,10 @@ public function testCanonicalUrlRewriteGenerate()
704
704
->expects ($ this ->once ())
705
705
->method ('getUrlPathWithSuffix ' )
706
706
->will ($ this ->returnValue ($ requestPath ));
707
+ $ this ->productUrlPathGenerator
708
+ ->expects ($ this ->once ())
709
+ ->method ('getUrlPath ' )
710
+ ->will ($ this ->returnValue ('urlPath ' ));
707
711
$ this ->productUrlPathGenerator
708
712
->expects ($ this ->once ())
709
713
->method ('getCanonicalUrlPath ' )
@@ -747,6 +751,36 @@ public function testCanonicalUrlRewriteGenerate()
747
751
);
748
752
}
749
753
754
+ /**
755
+ * Cover canonicalUrlRewriteGenerate().
756
+ */
757
+ public function testCanonicalUrlRewriteGenerateWithEmptyUrlPath ()
758
+ {
759
+ $ productId = 'product_id ' ;
760
+ $ storeId = 10 ;
761
+ $ product = $ this
762
+ ->getMockBuilder ('Magento\Catalog\Model\Product ' )
763
+ ->disableOriginalConstructor ()
764
+ ->getMock ();
765
+ $ productsByStores = [$ storeId => $ product ];
766
+ $ products = [
767
+ $ productId => $ productsByStores ,
768
+ ];
769
+
770
+ $ this ->setPropertyValue ($ this ->import , 'products ' , $ products );
771
+
772
+ $ this ->productUrlPathGenerator
773
+ ->expects ($ this ->once ())
774
+ ->method ('getUrlPath ' )
775
+ ->will ($ this ->returnValue ('' ));
776
+ $ this ->urlRewriteFactory
777
+ ->expects ($ this ->never ())
778
+ ->method ('create ' );
779
+
780
+ $ actualResult = $ this ->invokeMethod ($ this ->import , 'canonicalUrlRewriteGenerate ' );
781
+ $ this ->assertEquals ([], $ actualResult );
782
+ }
783
+
750
784
/**
751
785
* Cover categoriesUrlRewriteGenerate().
752
786
*/
0 commit comments