@@ -272,8 +272,6 @@ public function testCmsBlockResolverCacheDoesNotSaveNonExistentCmsBlock()
272272 // expected exception
273273 }
274274
275- print_r ($ e ->getResponseData ());
276-
277275 $ response ['headers ' ] = $ e ->getResponseHeaders ();
278276
279277 $ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ nonExistentBlock ]);
@@ -283,6 +281,62 @@ public function testCmsBlockResolverCacheDoesNotSaveNonExistentCmsBlock()
283281 );
284282 }
285283
284+ /**
285+ * @magentoConfigFixture default/system/full_page_cache/caching_application 2
286+ * @magentoDataFixture Magento/Cms/_files/block.php
287+ * @magentoDataFixture Magento/Cms/_files/blocks.php
288+ */
289+ public function testCmsBlockResolverCacheRetainsEntriesThatHaveNotBeenUpdated ()
290+ {
291+ // query block1
292+ $ block1 = $ this ->blockRepository ->getById ('fixture_block ' );
293+
294+ $ queryBlock1 = $ this ->getQuery ([
295+ $ block1 ->getIdentifier (),
296+ ]);
297+
298+ $ responseBlock1 = $ this ->graphQlQueryWithResponseHeaders ($ queryBlock1 );
299+
300+ $ cacheIdentityStringBlock1 = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ responseBlock1 , [$ block1 ]);
301+
302+ // query block2
303+ $ block2 = $ this ->blockRepository ->getById ('enabled_block ' );
304+
305+ $ queryBlock2 = $ this ->getQuery ([
306+ $ block2 ->getIdentifier (),
307+ ]);
308+
309+ $ responseBlock2 = $ this ->graphQlQueryWithResponseHeaders ($ queryBlock2 );
310+
311+ $ cacheIdentityStringBlock2 = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ responseBlock2 , [$ block2 ]);
312+
313+ // assert both cache entries are present
314+ $ this ->assertIsNumeric (
315+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringBlock1 ),
316+ 'Cache entry for block1 should be present '
317+ );
318+
319+ $ this ->assertIsNumeric (
320+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringBlock2 ),
321+ 'Cache entry for block2 should be present '
322+ );
323+
324+ // assert that cache is invalidated after block1 update
325+ $ block1 ->setContent ('Updated content ' );
326+ $ this ->blockRepository ->save ($ block1 );
327+
328+ $ this ->assertFalse (
329+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringBlock1 ),
330+ 'Cache entry for block1 should be invalidated after block1 update '
331+ );
332+
333+ // assert that cache is not invalidated after block1 update
334+ $ this ->assertIsNumeric (
335+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringBlock2 ),
336+ 'Cache entry for block2 should be present after block1 update '
337+ );
338+ }
339+
286340 private function getQuery (array $ identifiers ): string
287341 {
288342 $ identifiersStr = $ this ->getQuotedBlockIdentifiersListAsString ($ identifiers );
@@ -347,7 +401,6 @@ private function assertTagsByCacheIdentityAndBlocks(string $cacheIdentityString,
347401 $ tags = $ metadatas ['tags ' ];
348402
349403 $ expectedTags = [
350- $ cacheIdPrefix . strtoupper (Block::CACHE_TAG ),
351404 $ cacheIdPrefix . strtoupper (GraphQlResolverCache::CACHE_TAG ),
352405 $ cacheIdPrefix . 'MAGE ' ,
353406 ];
0 commit comments