File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
dev/tests/api-functional/testsuite/Magento/CmsGraphQl/Model/Resolver Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,43 @@ public function testCmsMultipleBlockResolverCacheAndInvalidationAsGuest()
130130 );
131131 }
132132
133+ /**
134+ * @magentoDataFixture Magento/Cms/_files/block.php
135+ */
136+ public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDeleted ()
137+ {
138+ $ block = $ this ->blockRepository ->getById ('fixture_block ' );
139+
140+ $ query = $ this ->getQuery ([
141+ $ block ->getIdentifier (),
142+ ]);
143+
144+ $ response = $ this ->graphQlQueryWithResponseHeaders ($ query );
145+
146+ $ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ block ]);
147+
148+ $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
149+ $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
150+
151+ $ this ->assertEqualsCanonicalizing (
152+ $ this ->generateExpectedDataFromBlocks ([$ block ]),
153+ $ cacheEntryDecoded
154+ );
155+
156+ $ this ->assertTagsByCacheIdentityAndBlocks (
157+ $ cacheIdentityString ,
158+ [$ block ]
159+ );
160+
161+ // assert that cache is invalidated after block deletion
162+ $ this ->blockRepository ->delete ($ block );
163+
164+ $ this ->assertFalse (
165+ $ this ->graphqlCache ->test ($ cacheIdentityString ),
166+ 'Cache entry should be invalidated after block deletion '
167+ );
168+ }
169+
133170 /**
134171 * @magentoDataFixture Magento/Cms/_files/block.php
135172 * @magentoDataFixture Magento/Store/_files/second_store.php
You can’t perform that action at this time.
0 commit comments