@@ -341,6 +341,54 @@ public function testMediaGalleryResolverCacheKeyAndTags()
341
341
$ this ->assertNotEquals ($ simpleProductCacheTags , $ simpleProductWithMediaCacheTags );
342
342
}
343
343
344
+ #[
345
+ DataFixture(ProductFixture::class, ['sku ' => 'product1 ' , 'media_gallery_entries ' => [[]]], as: 'product ' ),
346
+ ]
347
+ public function testThatThereAreNoOrphanedCacheIdsInTagFileAfterInvalidation ()
348
+ {
349
+ $ product = $ this ->productRepository ->get ('product1 ' );
350
+ $ this ->graphQlQuery ($ this ->getProductWithMediaGalleryQuery ($ product ));
351
+ $ this ->assertMediaGalleryResolverCacheRecordExists ($ product );
352
+
353
+ $ cacheKey = $ this ->getCacheKeyForMediaGalleryResolver ($ product );
354
+
355
+ // update media gallery-related field and assert cache is invalidated
356
+ $ this ->actionMechanismProvider ()['update media label ' ][0 ]($ product );
357
+ $ this ->assertMediaGalleryResolverCacheRecordDoesNotExist ($ product );
358
+
359
+ // assert cache id is not in GRAPHQL_QUERY_RESOLVER_RESULT tag file
360
+ $ cacheLowLevelFrontend = $ this ->graphQlResolverCache ->getLowLevelFrontend ();
361
+ $ cacheIdPrefix = $ cacheLowLevelFrontend ->getOption ('cache_id_prefix ' );
362
+ $ cacheBackend = $ cacheLowLevelFrontend ->getBackend ();
363
+
364
+ $ this ->assertNotContains (
365
+ $ cacheIdPrefix . $ cacheKey ,
366
+ $ cacheBackend ->getIdsMatchingTags ([
367
+ $ cacheIdPrefix . 'GRAPHQL_QUERY_RESOLVER_RESULT '
368
+ ]),
369
+ 'Cache id is still present in GRAPHQL_QUERY_RESOLVER_RESULT tag file after invalidation '
370
+ );
371
+
372
+ $ this ->assertNotContains (
373
+ $ cacheIdPrefix . $ cacheKey ,
374
+ $ cacheBackend ->getIdsMatchingTags ([
375
+ $ cacheIdPrefix . 'GQL_MEDIA_GALLERY '
376
+ ]),
377
+ 'Cache id is still present in GQL_MEDIA_GALLERY tag file after invalidation '
378
+ );
379
+
380
+ $ this ->assertNotContains (
381
+ $ cacheIdPrefix . $ cacheKey ,
382
+ $ cacheBackend ->getIdsMatchingTags ([
383
+ $ cacheIdPrefix . 'GQL_MEDIA_GALLERY_ ' . $ product ->getId (),
384
+ ]),
385
+ sprintf (
386
+ 'Cache id is still present in GQL_MEDIA_GALLERY_%s tag file after invalidation ' ,
387
+ $ product ->getId ()
388
+ )
389
+ );
390
+ }
391
+
344
392
/**
345
393
* @magentoApiDataFixture Magento/Catalog/_files/product_with_media_gallery.php
346
394
* @return void
0 commit comments