Skip to content
Snippets Groups Projects
Commit 3c3168bd authored by marina's avatar marina
Browse files

Update scheduledGenerateSitemaps unit test

parent 3fc3c1dc
Branches
No related merge requests found
......@@ -96,11 +96,11 @@ class ObserverTest extends \PHPUnit\Framework\TestCase
);
}
/**
* @expectedException \Exception
*/
public function testScheduledGenerateSitemapsThrowsException()
public function testScheduledGenerateSitemapsSendsExceptionEmail()
{
$exception = 'Sitemap Exception';
$transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class);
$this->scopeConfigMock->expects($this->once())->method('isSetFlag')->willReturn(true);
$this->collectionFactoryMock->expects($this->once())
......@@ -111,7 +111,53 @@ class ObserverTest extends \PHPUnit\Framework\TestCase
->method('getIterator')
->willReturn(new \ArrayIterator([$this->sitemapMock]));
$this->sitemapMock->expects($this->once())->method('generateXml')->willThrowException(new \Exception());
$this->sitemapMock->expects($this->once())->method('generateXml')->willThrowException(new \Exception($exception));
$this->scopeConfigMock->expects($this->at(1))
->method('getValue')
->with(
\Magento\Sitemap\Model\Observer::XML_PATH_ERROR_RECIPIENT,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
)
->willReturn('error-recipient@example.com');
$this->inlineTranslationMock->expects($this->once())
->method('suspend');
$this->transportBuilderMock->expects($this->once())
->method('setTemplateIdentifier')
->will($this->returnSelf());
$this->transportBuilderMock->expects($this->once())
->method('setTemplateOptions')
->with([
'area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE,
'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID,
])
->will($this->returnSelf());
$this->transportBuilderMock->expects($this->once())
->method('setTemplateVars')
->with(['warnings' => $exception])
->will($this->returnSelf());
$this->transportBuilderMock->expects($this->once())
->method('setFrom')
->will($this->returnSelf());
$this->transportBuilderMock->expects($this->once())
->method('addTo')
->will($this->returnSelf());
$this->transportBuilderMock->expects($this->once())
->method('getTransport')
->willReturn($transport);
$transport->expects($this->once())
->method('sendMessage');
$this->inlineTranslationMock->expects($this->once())
->method('resume');
$this->observer->scheduledGenerateSitemaps();
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment