Skip to content

Commit 3d0fa8f

Browse files
committed
MAGETWO-56556: [GITHUB PR#3779] Add dispatching of view_block_abstract_to_html_after event
- fix Unit tests
1 parent 79462ab commit 3d0fa8f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/internal/Magento/Framework/View/Test/Unit/Element/AbstractBlockTest.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ public function testToHtmlWhenModuleIsDisabled()
219219
* @param string|bool $cacheLifetime
220220
* @param string|bool $dataFromCache
221221
* @param string $dataForSaveCache
222+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsDispatchEvent
222223
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCacheLoad
223224
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCacheSave
224225
* @param string $expectedResult
@@ -229,6 +230,7 @@ public function testGetCacheLifetimeViaToHtml(
229230
$cacheLifetime,
230231
$dataFromCache,
231232
$dataForSaveCache,
233+
$expectsDispatchEvent,
232234
$expectsCacheLoad,
233235
$expectsCacheSave,
234236
$expectedResult
@@ -239,9 +241,8 @@ public function testGetCacheLifetimeViaToHtml(
239241
$this->block->setData('module_name', $moduleName);
240242
$this->block->setData('cache_lifetime', $cacheLifetime);
241243

242-
$this->eventManagerMock->expects($this->any())
243-
->method('dispatch')
244-
->with('view_block_abstract_to_html_before', ['block' => $this->block]);
244+
$this->eventManagerMock->expects($expectsDispatchEvent)
245+
->method('dispatch');
245246
$this->scopeConfigMock->expects($this->once())
246247
->method('getValue')
247248
->with('advanced/modules_disable_output/' . $moduleName, \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
@@ -278,6 +279,7 @@ public function getCacheLifetimeDataProvider()
278279
'cacheLifetime' => null,
279280
'dataFromCache' => 'dataFromCache',
280281
'dataForSaveCache' => '',
282+
'expectsDispatchEvent' => $this->exactly(2),
281283
'expectsCacheLoad' => $this->never(),
282284
'expectsCacheSave' => $this->never(),
283285
'expectedResult' => '',
@@ -286,6 +288,7 @@ public function getCacheLifetimeDataProvider()
286288
'cacheLifetime' => false,
287289
'dataFromCache' => 'dataFromCache',
288290
'dataForSaveCache' => '',
291+
'expectsDispatchEvent' => $this->exactly(2),
289292
'expectsCacheLoad' => $this->once(),
290293
'expectsCacheSave' => $this->never(),
291294
'expectedResult' => 'dataFromCache',
@@ -294,6 +297,7 @@ public function getCacheLifetimeDataProvider()
294297
'cacheLifetime' => 120,
295298
'dataFromCache' => 'dataFromCache',
296299
'dataForSaveCache' => '',
300+
'expectsDispatchEvent' => $this->exactly(2),
297301
'expectsCacheLoad' => $this->once(),
298302
'expectsCacheSave' => $this->never(),
299303
'expectedResult' => 'dataFromCache',
@@ -302,6 +306,7 @@ public function getCacheLifetimeDataProvider()
302306
'cacheLifetime' => '120string',
303307
'dataFromCache' => 'dataFromCache',
304308
'dataForSaveCache' => '',
309+
'expectsDispatchEvent' => $this->exactly(2),
305310
'expectsCacheLoad' => $this->once(),
306311
'expectsCacheSave' => $this->never(),
307312
'expectedResult' => 'dataFromCache',
@@ -310,6 +315,7 @@ public function getCacheLifetimeDataProvider()
310315
'cacheLifetime' => 120,
311316
'dataFromCache' => false,
312317
'dataForSaveCache' => '',
318+
'expectsDispatchEvent' => $this->exactly(2),
313319
'expectsCacheLoad' => $this->once(),
314320
'expectsCacheSave' => $this->once(),
315321
'expectedResult' => '',

0 commit comments

Comments
 (0)