2323
2424/**
2525 * Test storeConfig query cache
26+ *
27+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2628 */
2729class StoreConfigCacheTest extends GraphQLPageCacheAbstract
2830{
@@ -81,6 +83,11 @@ protected function setUp(): void
8183 /**
8284 * storeConfig query is cached.
8385 *
86+ * Test stores set up:
87+ * STORE - WEBSITE - STORE GROUP
88+ * default - base - main_website_store
89+ * test - base - main_website_store
90+ *
8491 * @magentoConfigFixture default/system/full_page_cache/caching_application 2
8592 * @magentoApiDataFixture Magento/Store/_files/store.php
8693 * @throws NoSuchEntityException
@@ -152,6 +159,11 @@ public function testGetStoreConfig(): void
152159 /**
153160 * Store scoped config change triggers purging only the cache of the changed store.
154161 *
162+ * Test stores set up:
163+ * STORE - WEBSITE - STORE GROUP
164+ * default - base - main_website_store
165+ * test - base - main_website_store
166+ *
155167 * @magentoConfigFixture default/system/full_page_cache/caching_application 2
156168 * @magentoApiDataFixture Magento/Store/_files/store.php
157169 * @throws NoSuchEntityException
@@ -244,6 +256,11 @@ public function testCachePurgedWithStoreScopeConfigChange(): void
244256 /**
245257 * Store change triggers purging only the cache of the changed store.
246258 *
259+ * Test stores set up:
260+ * STORE - WEBSITE - STORE GROUP
261+ * default - base - main_website_store
262+ * test - base - main_website_store
263+ *
247264 * @magentoConfigFixture default/system/full_page_cache/caching_application 2
248265 * @magentoApiDataFixture Magento/Store/_files/store.php
249266 * @throws NoSuchEntityException
@@ -341,9 +358,16 @@ public function testCachePurgedWithStoreChange(): void
341358 /**
342359 * Store group change triggers purging only the cache of the stores associated with the changed store group.
343360 *
361+ * Test stores set up:
362+ * STORE - WEBSITE - STORE GROUP
363+ * default - base - main_website_store
364+ * second_store_view - base - second_store
365+ * third_store_view - base - second_store
366+ *
344367 * @magentoConfigFixture default/system/full_page_cache/caching_application 2
345368 * @magentoApiDataFixture Magento/Store/_files/multiple_websites_with_store_groups_stores.php
346369 * @throws NoSuchEntityException
370+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
347371 */
348372 public function testCachePurgedWithStoreGroupChange (): void
349373 {
@@ -352,7 +376,6 @@ public function testCachePurgedWithStoreGroupChange(): void
352376
353377 // Query default store config
354378 $ responseDefaultStore = $ this ->graphQlQueryWithResponseHeaders ($ query );
355- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseDefaultStore ['headers ' ]);
356379 $ defaultStoreCacheId = $ responseDefaultStore ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
357380 // Verify we obtain a cache MISS at the 1st time
358381 $ this ->assertCacheMissAndReturnResponse (
@@ -368,9 +391,7 @@ public function testCachePurgedWithStoreGroupChange(): void
368391 '' ,
369392 ['Store ' => $ secondStoreCode ]
370393 );
371- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseThirdStore ['headers ' ]);
372394 $ secondStoreCacheId = $ responseThirdStore ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
373- $ this ->assertNotEquals ($ secondStoreCacheId , $ defaultStoreCacheId );
374395 // Verify we obtain a cache MISS at the 1st time
375396 $ secondStoreResponse = $ this ->assertCacheMissAndReturnResponse (
376397 $ query ,
@@ -379,10 +400,8 @@ public function testCachePurgedWithStoreGroupChange(): void
379400 'Store ' => $ secondStoreCode
380401 ]
381402 );
382- $ this ->assertArrayHasKey ('storeConfig ' , $ secondStoreResponse ['body ' ]);
383- $ secondStoreResponseResult = $ secondStoreResponse ['body ' ]['storeConfig ' ];
384403 $ secondStoreGroupName = 'Second store group ' ;
385- $ this ->assertEquals ($ secondStoreGroupName , $ secondStoreResponseResult ['store_group_name ' ]);
404+ $ this ->assertEquals ($ secondStoreGroupName , $ secondStoreResponse [ ' body ' ][ ' storeConfig ' ] ['store_group_name ' ]);
386405
387406 // Query third store config
388407 $ thirdStoreCode = 'third_store_view ' ;
@@ -392,7 +411,6 @@ public function testCachePurgedWithStoreGroupChange(): void
392411 '' ,
393412 ['Store ' => $ thirdStoreCode ]
394413 );
395- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseThirdStore ['headers ' ]);
396414 $ thirdStoreCacheId = $ responseThirdStore ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
397415 // Verify we obtain a cache MISS at the 1st time
398416 $ thirdStoreResponse = $ this ->assertCacheMissAndReturnResponse (
@@ -402,9 +420,7 @@ public function testCachePurgedWithStoreGroupChange(): void
402420 'Store ' => $ thirdStoreCode
403421 ]
404422 );
405- $ this ->assertArrayHasKey ('storeConfig ' , $ thirdStoreResponse ['body ' ]);
406- $ thirdStoreResponseResult = $ thirdStoreResponse ['body ' ]['storeConfig ' ];
407- $ this ->assertEquals ($ secondStoreGroupName , $ thirdStoreResponseResult ['store_group_name ' ]);
423+ $ this ->assertEquals ($ secondStoreGroupName , $ thirdStoreResponse ['body ' ]['storeConfig ' ]['store_group_name ' ]);
408424
409425 // Change store group name
410426 /** @var Group $storeGroup */
@@ -430,9 +446,10 @@ public function testCachePurgedWithStoreGroupChange(): void
430446 'Store ' => $ secondStoreCode
431447 ]
432448 );
433- $ this ->assertArrayHasKey ('storeConfig ' , $ secondStoreResponseMiss ['body ' ]);
434- $ secondStoreResponseMissResult = $ secondStoreResponseMiss ['body ' ]['storeConfig ' ];
435- $ this ->assertEquals ($ secondStoreGroupNewName , $ secondStoreResponseMissResult ['store_group_name ' ]);
449+ $ this ->assertEquals (
450+ $ secondStoreGroupNewName ,
451+ $ secondStoreResponseMiss ['body ' ]['storeConfig ' ]['store_group_name ' ]
452+ );
436453 // Verify we obtain a cache HIT at the 3rd time
437454 $ this ->assertCacheHitAndReturnResponse (
438455 $ query ,
@@ -451,9 +468,10 @@ public function testCachePurgedWithStoreGroupChange(): void
451468 'Store ' => $ thirdStoreCode
452469 ]
453470 );
454- $ this ->assertArrayHasKey ('storeConfig ' , $ thirdStoreResponseMiss ['body ' ]);
455- $ thirdStoreResponseMissResult = $ thirdStoreResponseMiss ['body ' ]['storeConfig ' ];
456- $ this ->assertEquals ($ secondStoreGroupNewName , $ thirdStoreResponseMissResult ['store_group_name ' ]);
471+ $ this ->assertEquals (
472+ $ secondStoreGroupNewName ,
473+ $ thirdStoreResponseMiss ['body ' ]['storeConfig ' ]['store_group_name ' ]
474+ );
457475 // Verify we obtain a cache HIT at the 3rd time
458476 $ this ->assertCacheHitAndReturnResponse (
459477 $ query ,
0 commit comments