diff --git a/app/code/Magento/Sitemap/Model/Sitemap.php b/app/code/Magento/Sitemap/Model/Sitemap.php index a26cbcc58bd2009de615c6d6f81b30d8d838139f..c8d15c7a855ea97afc9077af3db97c6ad4ff7c19 100644 --- a/app/code/Magento/Sitemap/Model/Sitemap.php +++ b/app/code/Magento/Sitemap/Model/Sitemap.php @@ -586,8 +586,9 @@ class Sitemap extends \Magento\Framework\Model\AbstractModel */ protected function _getStoreBaseUrl($type = \Magento\Framework\UrlInterface::URL_TYPE_LINK) { - $isSecure = $this->_storeManager->getStore($this->getStoreId())->isFrontUrlSecure(); - return rtrim($this->_storeManager->getStore($this->getStoreId())->getBaseUrl($type, $isSecure), '/') . '/'; + $store = $this->_storeManager->getStore($this->getStoreId()); + $isSecure = $store->isUrlSecure(); + return rtrim($store->getBaseUrl($type, $isSecure), '/') . '/'; } /** diff --git a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php index 297161fb9fd7b258955923607a2d2244e8cdd829..964d12b8ad15ac1b8436723a190ff557b725d545 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php @@ -478,32 +478,19 @@ class SitemapTest extends \PHPUnit_Framework_TestCase $model = $this->_getModelMock(true); - $storeMock = $this->getMockBuilder( - \Magento\Store\Model\Store::class - )->setMethods( - ['isFrontUrlSecure', 'getBaseUrl'] - )->disableOriginalConstructor()->getMock(); + $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 - ); + $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; } @@ -641,11 +628,9 @@ 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(); + $this->_storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) + ->setMethods(['getStore']) + ->getMockForAbstractClass(); $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $constructArguments = $objectManager->getConstructArguments(