@@ -36,7 +36,6 @@ class BlockByIdentifierTest extends TestCase
36
36
37
37
private const ASSERT_EMPTY_BLOCK_HTML = '' ;
38
38
private const ASSERT_CONTENT_HTML = self ::STUB_CONTENT ;
39
- private const ASSERT_NO_CACHE_IDENTITIES = [];
40
39
private const ASSERT_UNAVAILABLE_IDENTIFIER_BASED_IDENTITIES = [
41
40
BlockByIdentifier::CACHE_KEY_PREFIX . '_ ' . self ::STUB_UNAVAILABLE_IDENTIFIER ,
42
41
BlockByIdentifier::CACHE_KEY_PREFIX . '_ ' . self ::STUB_UNAVAILABLE_IDENTIFIER . '_ ' . self ::STUB_DEFAULT_STORE
@@ -68,15 +67,18 @@ protected function setUp(): void
68
67
$ this ->filterProviderMock ->method ('getBlockFilter ' )->willReturn ($ this ->getPassthroughFilterMock ());
69
68
}
70
69
71
- public function testBlockReturnsEmptyStringWhenNoIdentifierProvided (): void
70
+ public function testBlockThrowsInvalidArgumentExceptionWhenNoIdentifierProvided (): void
72
71
{
73
72
// Given
74
73
$ missingIdentifierBlock = $ this ->getTestedBlockUsingIdentifier (null );
75
74
$ this ->storeMock ->method ('getId ' )->willReturn (self ::STUB_DEFAULT_STORE );
76
75
77
76
// Expect
78
- $ this ->assertSame (self ::ASSERT_EMPTY_BLOCK_HTML , $ missingIdentifierBlock ->toHtml ());
79
- $ this ->assertSame (self ::ASSERT_NO_CACHE_IDENTITIES , $ missingIdentifierBlock ->getIdentities ());
77
+ $ this ->expectException (\InvalidArgumentException::class);
78
+ $ this ->expectExceptionMessage ('Expected value of `identifier` was not provided ' );
79
+
80
+ // When
81
+ $ missingIdentifierBlock ->toHtml ();
80
82
}
81
83
82
84
public function testBlockReturnsEmptyStringWhenIdentifierProvidedNotFound (): void
@@ -119,6 +121,7 @@ public function testBlockCacheIdentitiesContainCmsBlockIdentities(): void
119
121
// Given
120
122
$ cmsBlockMock = $ this ->createMock (Block::class);
121
123
$ cmsBlockMock ->method ('getId ' )->willReturn (self ::STUB_CMS_BLOCK_ID );
124
+ $ cmsBlockMock ->method ('isActive ' )->willReturn (true );
122
125
$ cmsBlockMock ->method ('getIdentifier ' )->willReturn (self ::STUB_EXISTING_IDENTIFIER );
123
126
$ cmsBlockMock ->method ('getIdentities ' )->willReturn (
124
127
[
@@ -173,15 +176,21 @@ private function getTestedBlockUsingIdentifier(?string $identifier): BlockByIden
173
176
* @param int $entityId
174
177
* @param string $identifier
175
178
* @param string $content
179
+ * @param bool $isActive
176
180
* @return MockObject|BlockInterface
177
181
*/
178
- private function getCmsBlockMock (int $ entityId , string $ identifier , string $ content ): BlockInterface
179
- {
182
+ private function getCmsBlockMock (
183
+ int $ entityId ,
184
+ string $ identifier ,
185
+ string $ content ,
186
+ bool $ isActive = true
187
+ ): BlockInterface {
180
188
$ cmsBlock = $ this ->createMock (BlockInterface::class);
181
189
182
190
$ cmsBlock ->method ('getId ' )->willReturn ($ entityId );
183
191
$ cmsBlock ->method ('getIdentifier ' )->willReturn ($ identifier );
184
192
$ cmsBlock ->method ('getContent ' )->willReturn ($ content );
193
+ $ cmsBlock ->method ('isActive ' )->willReturn ($ isActive );
185
194
186
195
return $ cmsBlock ;
187
196
}
0 commit comments