Skip to content

Commit

Permalink
B2B-2677: [MediaGallery]Implement data caching for GraphQL results on…
Browse files Browse the repository at this point in the history
… resolver level
  • Loading branch information
joanhe committed Jun 19, 2023
1 parent 58df76b commit b00dc07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function dehydrate(array &$resolvedValue): void
}

/**
* Dedydrate the resolved value of a media gallery entity.
* Dehydrate the resolved value of a media gallery entity.
*
* @param array $mediaGalleryEntityResolvedValue
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,9 @@ protected function setUp(): void
$this->graphQlResolverCache = $this->objectManager->get(GraphQlResolverCache::class);
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);

// first register secure area so we have permission to delete customer in tests
$this->registry = $this->objectManager->get(Registry::class);
$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', true);

parent::setUp();
}

protected function tearDown(): void
{
// reset secure area to false (was set to true in setUp so we could delete customer in tests)
$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', false);

parent::tearDown();
}

/**
* @magentoDbIsolation disabled
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_media_gallery_entries.php
Expand Down Expand Up @@ -183,11 +169,11 @@ public function testMediaGalleryResolverCacheKeyAndTags()

$simpleProduct = $this->productRepository->get($simpleProductSku);
$simpleProductCacheKey = $this->getCacheKeyForMediaGalleryResolver($simpleProduct);
$simplePrductCacheTags = $this->getCacheTagsUsedInMediaGalleryResolverCache($simpleProductCacheKey);
$simpleProductCacheTags = $this->getCacheTagsUsedInMediaGalleryResolverCache($simpleProductCacheKey);
// Verify cache tags are generated correctly for the simple product
$this->assertEquals(
$this->getExpectedCacheTags($simpleProduct),
$simplePrductCacheTags
$simpleProductCacheTags
);

// Test simple product with media
Expand All @@ -212,7 +198,7 @@ public function testMediaGalleryResolverCacheKeyAndTags()
$this->assertNotEquals($simpleProductCacheKey, $simpleProductWithMediaCacheKey);

// Verify different product query has different cache tags
$this->assertNotEquals($simplePrductCacheTags, $simpleProductWithMediaCacheTags);
$this->assertNotEquals($simpleProductCacheTags, $simpleProductWithMediaCacheTags);
}

/**
Expand Down

0 comments on commit b00dc07

Please sign in to comment.