@@ -350,35 +350,11 @@ public function testThatThereAreNoOrphanedCacheIdsInTagFileAfterInvalidation()
350
350
$ this ->graphQlQuery ($ this ->getProductWithMediaGalleryQuery ($ product ));
351
351
$ this ->assertMediaGalleryResolverCacheRecordExists ($ product );
352
352
353
- $ cacheKey = $ this ->getCacheKeyForMediaGalleryResolver ($ product );
354
-
355
353
// update media gallery-related field and assert cache is invalidated
356
354
$ this ->actionMechanismProvider ()['update media label ' ][0 ]($ product );
357
355
$ this ->assertMediaGalleryResolverCacheRecordDoesNotExist ($ product );
358
356
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_ ' . strtoupper ($ product ->getSku ()),
376
- ]),
377
- sprintf (
378
- 'Cache id is still present in GQL_MEDIA_GALLERY_%s tag file after invalidation ' ,
379
- strtoupper ($ product ->getSku ())
380
- )
381
- );
357
+ $ this ->assertCacheIdIsNotOrphanedInTagsForProduct ($ product );
382
358
}
383
359
384
360
/**
@@ -406,6 +382,40 @@ public function testCacheIsInvalidatedOnProductDeletion()
406
382
$ this ->assertMediaGalleryResolverCacheRecordDoesNotExist ($ product );
407
383
}
408
384
385
+ /**
386
+ * Assert that cache id is not present in any of the cache tag files for the $product.
387
+ *
388
+ * @param ProductInterface $product
389
+ * @return void
390
+ * @throws \Zend_Cache_Exception
391
+ */
392
+ private function assertCacheIdIsNotOrphanedInTagsForProduct (ProductInterface $ product )
393
+ {
394
+ $ cacheKey = $ this ->getCacheKeyForMediaGalleryResolver ($ product );
395
+ $ cacheLowLevelFrontend = $ this ->graphQlResolverCache ->getLowLevelFrontend ();
396
+ $ cacheIdPrefix = $ cacheLowLevelFrontend ->getOption ('cache_id_prefix ' );
397
+ $ cacheBackend = $ cacheLowLevelFrontend ->getBackend ();
398
+
399
+ $ this ->assertNotContains (
400
+ $ cacheIdPrefix . $ cacheKey ,
401
+ $ cacheBackend ->getIdsMatchingTags ([
402
+ $ cacheIdPrefix . 'GRAPHQL_QUERY_RESOLVER_RESULT '
403
+ ]),
404
+ 'Cache id is still present in GRAPHQL_QUERY_RESOLVER_RESULT tag file after invalidation '
405
+ );
406
+
407
+ $ this ->assertNotContains (
408
+ $ cacheIdPrefix . $ cacheKey ,
409
+ $ cacheBackend ->getIdsMatchingTags ([
410
+ $ cacheIdPrefix . 'GQL_MEDIA_GALLERY_ ' . strtoupper ($ product ->getSku ()),
411
+ ]),
412
+ sprintf (
413
+ 'Cache id is still present in GQL_MEDIA_GALLERY_%s tag file after invalidation ' ,
414
+ strtoupper ($ product ->getSku ())
415
+ )
416
+ );
417
+ }
418
+
409
419
/**
410
420
* Assert that media gallery cache record exists for the $product.
411
421
*
0 commit comments