@@ -36,7 +36,6 @@ class BlockByIdentifierTest extends TestCase
3636
3737 private const ASSERT_EMPTY_BLOCK_HTML = '' ;
3838 private const ASSERT_CONTENT_HTML = self ::STUB_CONTENT ;
39- private const ASSERT_NO_CACHE_IDENTITIES = [];
4039 private const ASSERT_UNAVAILABLE_IDENTIFIER_BASED_IDENTITIES = [
4140 BlockByIdentifier::CACHE_KEY_PREFIX . '_ ' . self ::STUB_UNAVAILABLE_IDENTIFIER ,
4241 BlockByIdentifier::CACHE_KEY_PREFIX . '_ ' . self ::STUB_UNAVAILABLE_IDENTIFIER . '_ ' . self ::STUB_DEFAULT_STORE
@@ -68,15 +67,18 @@ protected function setUp(): void
6867 $ this ->filterProviderMock ->method ('getBlockFilter ' )->willReturn ($ this ->getPassthroughFilterMock ());
6968 }
7069
71- public function testBlockReturnsEmptyStringWhenNoIdentifierProvided (): void
70+ public function testBlockThrowsInvalidArgumentExceptionWhenNoIdentifierProvided (): void
7271 {
7372 // Given
7473 $ missingIdentifierBlock = $ this ->getTestedBlockUsingIdentifier (null );
7574 $ this ->storeMock ->method ('getId ' )->willReturn (self ::STUB_DEFAULT_STORE );
7675
7776 // 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 ();
8082 }
8183
8284 public function testBlockReturnsEmptyStringWhenIdentifierProvidedNotFound (): void
@@ -119,6 +121,7 @@ public function testBlockCacheIdentitiesContainCmsBlockIdentities(): void
119121 // Given
120122 $ cmsBlockMock = $ this ->createMock (Block::class);
121123 $ cmsBlockMock ->method ('getId ' )->willReturn (self ::STUB_CMS_BLOCK_ID );
124+ $ cmsBlockMock ->method ('isActive ' )->willReturn (true );
122125 $ cmsBlockMock ->method ('getIdentifier ' )->willReturn (self ::STUB_EXISTING_IDENTIFIER );
123126 $ cmsBlockMock ->method ('getIdentities ' )->willReturn (
124127 [
@@ -173,15 +176,21 @@ private function getTestedBlockUsingIdentifier(?string $identifier): BlockByIden
173176 * @param int $entityId
174177 * @param string $identifier
175178 * @param string $content
179+ * @param bool $isActive
176180 * @return MockObject|BlockInterface
177181 */
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 {
180188 $ cmsBlock = $ this ->createMock (BlockInterface::class);
181189
182190 $ cmsBlock ->method ('getId ' )->willReturn ($ entityId );
183191 $ cmsBlock ->method ('getIdentifier ' )->willReturn ($ identifier );
184192 $ cmsBlock ->method ('getContent ' )->willReturn ($ content );
193+ $ cmsBlock ->method ('isActive ' )->willReturn ($ isActive );
185194
186195 return $ cmsBlock ;
187196 }
0 commit comments