Skip to content

Commit 8269b84

Browse files
committed
Expect email notification to send, and simplify setup a bit.
1 parent f3df323 commit 8269b84

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,19 @@ class ObserverTest extends \PHPUnit\Framework\TestCase
6464

6565
protected function setUp()
6666
{
67-
$this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
68-
->getMock();
69-
$this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
70-
->getMock();
67+
$this->objectManagerMock = $this->createMock(
68+
\Magento\Framework\ObjectManagerInterface::class
69+
);
70+
$this->scopeConfigMock = $this->createMock(
71+
\Magento\Framework\App\Config\ScopeConfigInterface::class
72+
);
7173
$this->collectionFactoryMock = $this->getMockBuilder(
7274
\Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory::class
7375
)->disableOriginalConstructor()
7476
->setMethods(['create'])
7577
->getMock();
76-
$this->sitemapCollectionMock = $this->createPartialMock(
77-
\Magento\Sitemap\Model\ResourceModel\Sitemap\Collection::class,
78-
['getIterator']
78+
$this->sitemapCollectionMock = $this->createMock(
79+
\Magento\Sitemap\Model\ResourceModel\Sitemap\Collection::class
7980
);
8081
$this->sitemapMock = $this->createPartialMock(
8182
\Magento\Sitemap\Model\Sitemap::class,
@@ -130,6 +131,10 @@ public function testScheduledGenerateSitemapsSendsExceptionEmail()
130131
)
131132
->willReturn('[email protected]');
132133

134+
$this->emailNotificationMock->expects($this->once())
135+
->method('sendErrors')
136+
->with(['Sitemap Exception']);
137+
133138
$this->observer->scheduledGenerateSitemaps();
134139
}
135140
}

0 commit comments

Comments
 (0)