@@ -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,33 @@ function ($from, $to) {
473
478
474
479
$ model = $ this ->_getModelMock (true );
475
480
481
+ $ storeMock = $ this ->getMockBuilder (
482
+ \Magento \Store \Model \Store::class
483
+ )->setMethods (
484
+ ['isFrontUrlSecure ' , 'getBaseUrl ' ]
485
+ )->disableOriginalConstructor ()->getMock ();
486
+ $ storeMock ->expects ($ this ->atLeastOnce ())->method ('isFrontUrlSecure ' )->willReturn (false );
487
+ $ storeMock ->expects (
488
+ $ this ->atLeastOnce ()
489
+ )->method (
490
+ 'getBaseUrl '
491
+ )->with (
492
+ $ this ->isType ('string ' ),
493
+ false
494
+ )->willReturn (
495
+ 'http://store.com/ '
496
+ );
497
+
498
+ $ this ->_storeManagerMock ->expects (
499
+ $ this ->atLeastOnce ()
500
+ )->method (
501
+ 'getStore '
502
+ )->with (
503
+ 1
504
+ )->willReturn (
505
+ $ storeMock
506
+ );
507
+
476
508
return $ model ;
477
509
}
478
510
@@ -490,7 +522,6 @@ protected function _getModelMock($mockBeforeSave = false)
490
522
'_getBaseDir ' ,
491
523
'_getFileObject ' ,
492
524
'_afterSave ' ,
493
- '_getStoreBaseUrl ' ,
494
525
'_getCurrentDateTime ' ,
495
526
'_getCategoryItemsCollection ' ,
496
527
'_getProductItemsCollection ' ,
@@ -562,7 +593,6 @@ protected function _getModelMock($mockBeforeSave = false)
562
593
)->getMock ();
563
594
564
595
$ 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
596
$ model ->expects (
567
597
$ this ->any ()
568
598
)->method (
@@ -611,13 +641,21 @@ protected function _getModelConstructorArgs()
611
641
)->disableOriginalConstructor ()->getMock ();
612
642
$ cmsFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ this ->_sitemapCmsPageMock ));
613
643
644
+ $ this ->_storeManagerMock = $ this ->getMockBuilder (
645
+ \Magento \Store \Model \StoreManagerInterface::class
646
+ )->setMethods (
647
+ ['getStore ' ]
648
+ )->getMockForAbstractClass ();
649
+
650
+
614
651
$ objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
615
652
$ constructArguments = $ objectManager ->getConstructArguments (
616
653
\Magento \Sitemap \Model \Sitemap::class,
617
654
[
618
655
'categoryFactory ' => $ categoryFactory ,
619
656
'productFactory ' => $ productFactory ,
620
657
'cmsFactory ' => $ cmsFactory ,
658
+ 'storeManager ' => $ this ->_storeManagerMock ,
621
659
'sitemapData ' => $ this ->_helperMockSitemap ,
622
660
'filesystem ' => $ this ->_filesystemMock
623
661
]
0 commit comments