diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php index f94a20510478bc8e5dd60c561bce23fe70e15310..6affe7a93b36ef2aff6c03eb51609c95f62a5db4 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php @@ -50,6 +50,11 @@ class SitemapTest extends \PHPUnit_Framework_TestCase */ protected $_fileMock; + /** + * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $_storeManagerMock; + /** * Set helper mocks, create resource model mock */ @@ -473,6 +478,33 @@ class SitemapTest extends \PHPUnit_Framework_TestCase $model = $this->_getModelMock(true); + $storeMock = $this->getMockBuilder( + \Magento\Store\Model\Store::class + )->setMethods( + ['isFrontUrlSecure', 'getBaseUrl'] + )->disableOriginalConstructor()->getMock(); + $storeMock->expects($this->atLeastOnce())->method('isFrontUrlSecure')->willReturn(false); + $storeMock->expects( + $this->atLeastOnce() + )->method( + 'getBaseUrl' + )->with( + $this->isType('string'), + false + )->willReturn( + 'http://store.com/' + ); + + $this->_storeManagerMock->expects( + $this->atLeastOnce() + )->method( + 'getStore' + )->with( + 1 + )->willReturn( + $storeMock + ); + return $model; } @@ -490,7 +522,6 @@ class SitemapTest extends \PHPUnit_Framework_TestCase '_getBaseDir', '_getFileObject', '_afterSave', - '_getStoreBaseUrl', '_getCurrentDateTime', '_getCategoryItemsCollection', '_getProductItemsCollection', @@ -562,7 +593,6 @@ class SitemapTest extends \PHPUnit_Framework_TestCase )->getMock(); $model->expects($this->any())->method('_getResource')->will($this->returnValue($this->_resourceMock)); - $model->expects($this->any())->method('_getStoreBaseUrl')->will($this->returnValue('http://store.com/')); $model->expects( $this->any() )->method( @@ -611,6 +641,13 @@ class SitemapTest extends \PHPUnit_Framework_TestCase )->disableOriginalConstructor()->getMock(); $cmsFactory->expects($this->any())->method('create')->will($this->returnValue($this->_sitemapCmsPageMock)); + $this->_storeManagerMock = $this->getMockBuilder( + \Magento\Store\Model\StoreManagerInterface::class + )->setMethods( + ['getStore'] + )->getMockForAbstractClass(); + + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $constructArguments = $objectManager->getConstructArguments( \Magento\Sitemap\Model\Sitemap::class, @@ -618,6 +655,7 @@ class SitemapTest extends \PHPUnit_Framework_TestCase 'categoryFactory' => $categoryFactory, 'productFactory' => $productFactory, 'cmsFactory' => $cmsFactory, + 'storeManager' => $this->_storeManagerMock, 'sitemapData' => $this->_helperMockSitemap, 'filesystem' => $this->_filesystemMock ]