|
14 | 14 | use Magento\GraphQlCache\Model\CacheId\CacheIdCalculator;
|
15 | 15 | use Magento\Store\Model\StoreManagerInterface;
|
16 | 16 | use Magento\TestFramework\ObjectManager;
|
| 17 | +use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException; |
17 | 18 | use Magento\TestFramework\TestCase\GraphQlAbstract;
|
18 | 19 | use Magento\Widget\Model\Template\FilterEmulate;
|
19 | 20 |
|
@@ -48,6 +49,13 @@ protected function setUp(): void
|
48 | 49 | $this->storeManager = $objectManager->get(StoreManagerInterface::class);
|
49 | 50 | }
|
50 | 51 |
|
| 52 | + protected function tearDown(): void |
| 53 | + { |
| 54 | + $this->graphqlCache->clean(); |
| 55 | + |
| 56 | + parent::tearDown(); |
| 57 | + } |
| 58 | + |
51 | 59 | /**
|
52 | 60 | * @magentoDataFixture Magento/Cms/_files/blocks.php
|
53 | 61 | */
|
@@ -246,6 +254,35 @@ public function testCmsBlockResolverCacheIsInvalidatedAfterChangingItsStoreView(
|
246 | 254 | );
|
247 | 255 | }
|
248 | 256 |
|
| 257 | + /** |
| 258 | + * @magentoConfigFixture default/system/full_page_cache/caching_application 2 |
| 259 | + * @return void |
| 260 | + */ |
| 261 | + public function testCmsBlockResolverCacheDoesNotSaveNonExistentCmsBlock() |
| 262 | + { |
| 263 | + $nonExistentBlock = ObjectManager::getInstance()->create(BlockInterface::class); |
| 264 | + $nonExistentBlock->setIdentifier('non-existent-block'); |
| 265 | + |
| 266 | + $query = $this->getQuery([$nonExistentBlock->getIdentifier()]); |
| 267 | + |
| 268 | + try { |
| 269 | + $response = $this->graphQlQueryWithResponseHeaders($query); |
| 270 | + $this->fail('Expected exception was not thrown'); |
| 271 | + } catch (ResponseContainsErrorsException $e) { |
| 272 | + // expected exception |
| 273 | + } |
| 274 | + |
| 275 | + print_r($e->getResponseData()); |
| 276 | + |
| 277 | + $response['headers'] = $e->getResponseHeaders(); |
| 278 | + |
| 279 | + $cacheIdentityString = $this->getResolverCacheKeyFromResponseAndBlocks($response, [$nonExistentBlock]); |
| 280 | + |
| 281 | + $this->assertFalse( |
| 282 | + $this->graphqlCache->load($cacheIdentityString) |
| 283 | + ); |
| 284 | + } |
| 285 | + |
249 | 286 | private function getQuery(array $identifiers): string
|
250 | 287 | {
|
251 | 288 | $identifiersStr = $this->getQuotedBlockIdentifiersListAsString($identifiers);
|
|
0 commit comments