Skip to content

Commit 7da80b4

Browse files
MAGETWO-59785: Incorrect URLs in sitemap when generated from admin with 'Use Secure URLs in Admin' = Yes
Used API methods. Reformatted the code.
1 parent 3c0df73 commit 7da80b4

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

app/code/Magento/Sitemap/Model/Sitemap.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,8 +586,9 @@ protected function _getBaseDir()
586586
*/
587587
protected function _getStoreBaseUrl($type = \Magento\Framework\UrlInterface::URL_TYPE_LINK)
588588
{
589-
$isSecure = $this->_storeManager->getStore($this->getStoreId())->isFrontUrlSecure();
590-
return rtrim($this->_storeManager->getStore($this->getStoreId())->getBaseUrl($type, $isSecure), '/') . '/';
589+
$store = $this->_storeManager->getStore($this->getStoreId());
590+
$isSecure = $store->isUrlSecure();
591+
return rtrim($store->getBaseUrl($type, $isSecure), '/') . '/';
591592
}
592593

593594
/**

app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -478,32 +478,19 @@ function ($from, $to) {
478478

479479
$model = $this->_getModelMock(true);
480480

481-
$storeMock = $this->getMockBuilder(
482-
\Magento\Store\Model\Store::class
483-
)->setMethods(
484-
['isFrontUrlSecure', 'getBaseUrl']
485-
)->disableOriginalConstructor()->getMock();
481+
$storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
482+
->setMethods(['isFrontUrlSecure', 'getBaseUrl'])
483+
->disableOriginalConstructor()
484+
->getMock();
486485
$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-
);
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);
507494

508495
return $model;
509496
}
@@ -641,11 +628,9 @@ protected function _getModelConstructorArgs()
641628
)->disableOriginalConstructor()->getMock();
642629
$cmsFactory->expects($this->any())->method('create')->will($this->returnValue($this->_sitemapCmsPageMock));
643630

644-
$this->_storeManagerMock = $this->getMockBuilder(
645-
\Magento\Store\Model\StoreManagerInterface::class
646-
)->setMethods(
647-
['getStore']
648-
)->getMockForAbstractClass();
631+
$this->_storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
632+
->setMethods(['getStore'])
633+
->getMockForAbstractClass();
649634

650635
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
651636
$constructArguments = $objectManager->getConstructArguments(

0 commit comments

Comments
 (0)