@@ -272,8 +272,6 @@ public function testCmsBlockResolverCacheDoesNotSaveNonExistentCmsBlock()
272
272
// expected exception
273
273
}
274
274
275
- print_r ($ e ->getResponseData ());
276
-
277
275
$ response ['headers ' ] = $ e ->getResponseHeaders ();
278
276
279
277
$ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ nonExistentBlock ]);
@@ -283,6 +281,62 @@ public function testCmsBlockResolverCacheDoesNotSaveNonExistentCmsBlock()
283
281
);
284
282
}
285
283
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
+
286
340
private function getQuery (array $ identifiers ): string
287
341
{
288
342
$ identifiersStr = $ this ->getQuotedBlockIdentifiersListAsString ($ identifiers );
@@ -347,7 +401,6 @@ private function assertTagsByCacheIdentityAndBlocks(string $cacheIdentityString,
347
401
$ tags = $ metadatas ['tags ' ];
348
402
349
403
$ expectedTags = [
350
- $ cacheIdPrefix . strtoupper (Block::CACHE_TAG ),
351
404
$ cacheIdPrefix . strtoupper (GraphQlResolverCache::CACHE_TAG ),
352
405
$ cacheIdPrefix . 'MAGE ' ,
353
406
];
0 commit comments