Skip to content

Commit a91b551

Browse files
MAGETWO-59785: Incorrect URLs in sitemap when generated from admin with 'Use Secure URLs in Admin' = Yes
Modified sitemap unit test to cover the fix changes.
1 parent 1e05533 commit a91b551

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

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

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ class SitemapTest extends \PHPUnit_Framework_TestCase
5050
*/
5151
protected $_fileMock;
5252

53+
/**
54+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
55+
*/
56+
private $_storeManagerMock;
57+
5358
/**
5459
* Set helper mocks, create resource model mock
5560
*/
@@ -473,6 +478,33 @@ function ($from, $to) {
473478

474479
$model = $this->_getModelMock(true);
475480

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+
476508
return $model;
477509
}
478510

@@ -490,7 +522,6 @@ protected function _getModelMock($mockBeforeSave = false)
490522
'_getBaseDir',
491523
'_getFileObject',
492524
'_afterSave',
493-
'_getStoreBaseUrl',
494525
'_getCurrentDateTime',
495526
'_getCategoryItemsCollection',
496527
'_getProductItemsCollection',
@@ -562,7 +593,6 @@ protected function _getModelMock($mockBeforeSave = false)
562593
)->getMock();
563594

564595
$model->expects($this->any())->method('_getResource')->will($this->returnValue($this->_resourceMock));
565-
$model->expects($this->any())->method('_getStoreBaseUrl')->will($this->returnValue('http://store.com/'));
566596
$model->expects(
567597
$this->any()
568598
)->method(
@@ -611,13 +641,21 @@ protected function _getModelConstructorArgs()
611641
)->disableOriginalConstructor()->getMock();
612642
$cmsFactory->expects($this->any())->method('create')->will($this->returnValue($this->_sitemapCmsPageMock));
613643

644+
$this->_storeManagerMock = $this->getMockBuilder(
645+
\Magento\Store\Model\StoreManagerInterface::class
646+
)->setMethods(
647+
['getStore']
648+
)->getMockForAbstractClass();
649+
650+
614651
$objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
615652
$constructArguments = $objectManager->getConstructArguments(
616653
\Magento\Sitemap\Model\Sitemap::class,
617654
[
618655
'categoryFactory' => $categoryFactory,
619656
'productFactory' => $productFactory,
620657
'cmsFactory' => $cmsFactory,
658+
'storeManager' => $this->_storeManagerMock,
621659
'sitemapData' => $this->_helperMockSitemap,
622660
'filesystem' => $this->_filesystemMock
623661
]

0 commit comments

Comments
 (0)