Skip to content

Commit 6c137a8

Browse files
#10045 Fix unit tests
1 parent 79d15ad commit 6c137a8

File tree

3 files changed

+32
-7
lines changed

3 files changed

+32
-7
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public function testGetItemsEmpty()
2424
CmsPageSitemapItemResolver::XML_PATH_PAGE_PRIORITY => '1.0',
2525
]);
2626

27-
$cmsPageCollectionMock = $this->getCmsPageCollectionMock([]);
28-
$cmsPageFactoryMock = $this->getCmsPageFactoryMock($cmsPageCollectionMock);
27+
$cmsPageMock = $this->getCmsPageCollectionMock([]);
28+
$cmsPageFactoryMock = $this->getCmsPageFactoryMock($cmsPageMock);
2929
$itemFactoryMock = $this->getItemFactoryMock();
3030

3131
$resolver = new CmsPageSitemapItemResolver($storeConfigMock, $cmsPageFactoryMock, $itemFactoryMock);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ public function sitemapItemsProvider()
5252
for ($i = 1; $i < 5; $i++) {
5353
$itemProviders = [];
5454
$expectedItems = [];
55-
for ($i = 1; $i < $maxProviders = random_int(1, 5); $i++) {
55+
$maxProviders = random_int(1, 5);
56+
for ($i = 1; $i < $maxProviders; $i++) {
5657
$items = [];
57-
for ($i = 1; $i < $maxItems = random_int(2, 5); $i++) {
58+
$maxItems = random_int(2, 5);
59+
for ($i = 1; $i < $maxItems; $i++) {
5860
$sitemapItem = $this->getMockForAbstractClass(SitemapItemInterface::class);
5961
$items[] = $sitemapItem;
6062
$expectedItems[] = $sitemapItem;

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Sitemap\Test\Unit\Model;
77

8+
use Magento\Sitemap\Model\SitemapItem;
89
use Magento\Sitemap\Model\SitemapItemResolverInterface;
910

1011
/**
@@ -155,9 +156,6 @@ protected function setUp()
155156
);
156157

157158
$this->itemResolverMock = $this->getMockForAbstractClass(SitemapItemResolverInterface::class);
158-
$this->itemResolverMock->expects(self::any())
159-
->method('getItems')
160-
->willReturn([]);
161159
}
162160

163161
/**
@@ -587,6 +585,31 @@ protected function _getModelMock($mockBeforeSave = false)
587585
);
588586
$this->_sitemapCmsPageMock->expects($this->any())->method('getCollection')->will($this->returnValue([]));
589587

588+
$this->itemResolverMock->expects(self::any())
589+
->method('getItems')
590+
->willReturn([
591+
new SitemapItem('category.html', '1.0', 'daily', '2012-12-21 00:00:00'),
592+
new SitemapItem('/category/sub-category.html', '1.0', 'daily', '2012-12-21 00:00:00'),
593+
new SitemapItem('product.html', '0.5', 'monthly', '2012-12-21 00:00:00'),
594+
new SitemapItem('product2.html', '0.5', 'monthly', '2012-12-21 00:00:00', new \Magento\Framework\DataObject(
595+
[
596+
'collection' => [
597+
new \Magento\Framework\DataObject(
598+
[
599+
'url' => $storeBaseMediaUrl.'i/m/image1.png',
600+
'caption' => 'caption & > title < "'
601+
]
602+
),
603+
new \Magento\Framework\DataObject(
604+
['url' => $storeBaseMediaUrl.'i/m/image_no_caption.png', 'caption' => null]
605+
),
606+
],
607+
'thumbnail' => $storeBaseMediaUrl.'t/h/thumbnail.jpg',
608+
'title' => 'Product & > title < "',
609+
]
610+
))
611+
]);
612+
590613
/** @var $model \Magento\Sitemap\Model\Sitemap */
591614
$model = $this->getMockBuilder(
592615
\Magento\Sitemap\Model\Sitemap::class

0 commit comments

Comments
 (0)