1010use Magento \Cms \Api \Data \BlockInterface ;
1111use Magento \Cms \Api \GetBlockByIdentifierInterface ;
1212use Magento \Cms \Block \BlockByIdentifier ;
13+ use Magento \Cms \Model \Block ;
1314use Magento \Cms \Model \Template \FilterProvider ;
1415use Magento \Framework \App \Config \ScopeConfigInterface ;
1516use Magento \Framework \Event \ManagerInterface ;
2122use PHPUnit \Framework \MockObject \MockObject ;
2223use PHPUnit \Framework \TestCase ;
2324
25+ /**
26+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
27+ */
2428class BlockByIdentifierTest extends TestCase
2529{
2630 private const STUB_MODULE_OUTPUT_DISABLED = false ;
@@ -37,6 +41,8 @@ class BlockByIdentifierTest extends TestCase
3741 BlockByIdentifier::CACHE_KEY_PREFIX . '_ ' . self ::STUB_UNAVAILABLE_IDENTIFIER ,
3842 BlockByIdentifier::CACHE_KEY_PREFIX . '_ ' . self ::STUB_UNAVAILABLE_IDENTIFIER . '_ ' . self ::STUB_DEFAULT_STORE
3943 ];
44+ private const STUB_CMS_BLOCK_IDENTITY_BY_ID = 'CMS_BLOCK_ ' . self ::STUB_CMS_BLOCK_ID ;
45+ private const STUB_CMS_BLOCK_IDENTITY_BY_IDENTIFIER = 'CMS_BLOCK_ ' . self ::STUB_EXISTING_IDENTIFIER ;
4046
4147 /** @var MockObject|GetBlockByIdentifierInterface */
4248 private $ getBlockByIdentifierMock ;
@@ -108,14 +114,19 @@ public function testBlockReturnsCmsContentsWhenIdentifierFound(): void
108114 $ this ->assertSame (self ::ASSERT_CONTENT_HTML , $ block ->toHtml ());
109115 }
110116
111- public function testBlockCacheIdentitiesContainExplicitScopeInformation (): void
117+ public function testBlockCacheIdentitiesContainCmsBlockIdentities (): void
112118 {
113119 // Given
114- $ cmsBlockMock = $ this ->getCmsBlockMock (
115- self ::STUB_CMS_BLOCK_ID ,
116- self ::STUB_EXISTING_IDENTIFIER ,
117- self ::STUB_CONTENT
120+ $ cmsBlockMock = $ this ->createMock (Block::class);
121+ $ cmsBlockMock ->method ('getId ' )->willReturn (self ::STUB_CMS_BLOCK_ID );
122+ $ cmsBlockMock ->method ('getIdentifier ' )->willReturn (self ::STUB_EXISTING_IDENTIFIER );
123+ $ cmsBlockMock ->method ('getIdentities ' )->willReturn (
124+ [
125+ self ::STUB_CMS_BLOCK_IDENTITY_BY_ID ,
126+ self ::STUB_CMS_BLOCK_IDENTITY_BY_IDENTIFIER
127+ ]
118128 );
129+
119130 $ this ->storeMock ->method ('getId ' )->willReturn (self ::STUB_DEFAULT_STORE );
120131 $ this ->getBlockByIdentifierMock ->method ('execute ' )
121132 ->with (self ::STUB_EXISTING_IDENTIFIER , self ::STUB_DEFAULT_STORE )
@@ -127,10 +138,8 @@ public function testBlockCacheIdentitiesContainExplicitScopeInformation(): void
127138
128139 // Then
129140 $ this ->assertContains ($ this ->getIdentityStubById (self ::STUB_CMS_BLOCK_ID ), $ identities );
130- $ this ->assertContains (
131- $ this ->getIdentityStubByIdentifier (self ::STUB_EXISTING_IDENTIFIER , self ::STUB_DEFAULT_STORE ),
132- $ identities
133- );
141+ $ this ->assertContains (self ::STUB_CMS_BLOCK_IDENTITY_BY_ID , $ identities );
142+ $ this ->assertContains (self ::STUB_CMS_BLOCK_IDENTITY_BY_IDENTIFIER , $ identities );
134143 }
135144
136145 /**
0 commit comments