Skip to content

Commit 80e375f

Browse files
author
Roman Lytvynenko
committed
MC-37306: Sitemap generated by cron have wrong image URL (cache path)
1 parent 99c59a2 commit 80e375f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,36 @@ public function testScheduledGenerateSitemapsSendsExceptionEmail()
142142

143143
$this->observer->scheduledGenerateSitemaps();
144144
}
145+
146+
/**
147+
* Test if cron scheduled XML sitemap generation will start and stop the store environment emulation
148+
*
149+
* @throws \Exception
150+
*/
151+
public function testCronGenerateSitemapEnvironmentEmulation()
152+
{
153+
$storeId = 1;
154+
155+
$this->scopeConfigMock->expects($this->once())->method('isSetFlag')->willReturn(true);
156+
157+
$this->collectionFactoryMock->expects($this->once())
158+
->method('create')
159+
->willReturn($this->sitemapCollectionMock);
160+
161+
$this->sitemapCollectionMock->expects($this->any())
162+
->method('getIterator')
163+
->willReturn(new \ArrayIterator([$this->sitemapMock]));
164+
165+
$this->sitemapMock->expects($this->at(0))
166+
->method('getStoreId')
167+
->willReturn($storeId);
168+
169+
$this->appEmulationMock->expects($this->once())
170+
->method('startEnvironmentEmulation');
171+
172+
$this->appEmulationMock->expects($this->once())
173+
->method('stopEnvironmentEmulation');
174+
175+
$this->observer->scheduledGenerateSitemaps();
176+
}
145177
}

0 commit comments

Comments
 (0)