Skip to content

Commit 9b82e73

Browse files
committed
B2B-2677: [MediaGallery]Implement data caching for GraphQL results on resolver level
- Add testCacheIsInvalidatedOnProductDeletion
1 parent 5d3db70 commit 9b82e73

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ResolverCache/MediaGalleryTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,31 @@ public function testMediaGalleryResolverCacheKeyAndTags()
310310
$this->assertNotEquals($simpleProductCacheTags, $simpleProductWithMediaCacheTags);
311311
}
312312

313+
/**
314+
* @magentoApiDataFixture Magento/Catalog/_files/product_with_media_gallery.php
315+
* @return void
316+
*/
317+
public function testCacheIsInvalidatedOnProductDeletion()
318+
{
319+
$product = $this->productRepository->get('simple_product_with_media');
320+
$query = $this->getProductWithMediaGalleryQuery($product);
321+
$this->graphQlQuery($query);
322+
$this->assertMediaGalleryResolverCacheRecordExists($product);
323+
324+
$registry = $this->objectManager->get(\Magento\Framework\Registry::class);
325+
/** @var ProductRepositoryInterface $productRepository */
326+
$registry->unregister('isSecureArea');
327+
$registry->register('isSecureArea', true);
328+
329+
$this->productRepository->delete($product);
330+
331+
$registry->unregister('isSecureArea');
332+
$registry->register('isSecureArea', false);
333+
334+
// assert cache is invalidated
335+
$this->assertMediaGalleryResolverCacheRecordDoesNotExist($product);
336+
}
337+
313338
/**
314339
* Assert that media gallery cache record exists for the $product.
315340
*

0 commit comments

Comments
 (0)