@@ -50,6 +50,11 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
50
50
*/
51
51
protected $ _fileMock ;
52
52
53
+ /**
54
+ * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
55
+ */
56
+ private $ storeManagerMock ;
57
+
53
58
/**
54
59
* Set helper mocks, create resource model mock
55
60
*/
@@ -473,6 +478,20 @@ function ($from, $to) {
473
478
474
479
$ model = $ this ->_getModelMock (true );
475
480
481
+ $ storeMock = $ this ->getMockBuilder (\Magento \Store \Model \Store::class)
482
+ ->setMethods (['isFrontUrlSecure ' , 'getBaseUrl ' ])
483
+ ->disableOriginalConstructor ()
484
+ ->getMock ();
485
+ $ storeMock ->expects ($ this ->atLeastOnce ())->method ('isFrontUrlSecure ' )->willReturn (false );
486
+ $ storeMock ->expects ($ this ->atLeastOnce ())
487
+ ->method ('getBaseUrl ' )
488
+ ->with ($ this ->isType ('string ' ), false )
489
+ ->willReturn ('http://store.com/ ' );
490
+ $ this ->storeManagerMock ->expects ($ this ->atLeastOnce ())
491
+ ->method ('getStore ' )
492
+ ->with (1 )
493
+ ->willReturn ($ storeMock );
494
+
476
495
return $ model ;
477
496
}
478
497
@@ -490,7 +509,6 @@ protected function _getModelMock($mockBeforeSave = false)
490
509
'_getBaseDir ' ,
491
510
'_getFileObject ' ,
492
511
'_afterSave ' ,
493
- '_getStoreBaseUrl ' ,
494
512
'_getCurrentDateTime ' ,
495
513
'_getCategoryItemsCollection ' ,
496
514
'_getProductItemsCollection ' ,
@@ -562,7 +580,6 @@ protected function _getModelMock($mockBeforeSave = false)
562
580
)->getMock ();
563
581
564
582
$ model ->expects ($ this ->any ())->method ('_getResource ' )->will ($ this ->returnValue ($ this ->_resourceMock ));
565
- $ model ->expects ($ this ->any ())->method ('_getStoreBaseUrl ' )->will ($ this ->returnValue ('http://store.com/ ' ));
566
583
$ model ->expects (
567
584
$ this ->any ()
568
585
)->method (
@@ -611,13 +628,18 @@ protected function _getModelConstructorArgs()
611
628
)->disableOriginalConstructor ()->getMock ();
612
629
$ cmsFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ this ->_sitemapCmsPageMock ));
613
630
631
+ $ this ->storeManagerMock = $ this ->getMockBuilder (\Magento \Store \Model \StoreManagerInterface::class)
632
+ ->setMethods (['getStore ' ])
633
+ ->getMockForAbstractClass ();
634
+
614
635
$ objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
615
636
$ constructArguments = $ objectManager ->getConstructArguments (
616
637
\Magento \Sitemap \Model \Sitemap::class,
617
638
[
618
639
'categoryFactory ' => $ categoryFactory ,
619
640
'productFactory ' => $ productFactory ,
620
641
'cmsFactory ' => $ cmsFactory ,
642
+ 'storeManager ' => $ this ->storeManagerMock ,
621
643
'sitemapData ' => $ this ->_helperMockSitemap ,
622
644
'filesystem ' => $ this ->_filesystemMock
623
645
]
0 commit comments