23
23
24
24
/**
25
25
* Test storeConfig query cache
26
+ *
27
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26
28
*/
27
29
class StoreConfigCacheTest extends GraphQLPageCacheAbstract
28
30
{
@@ -81,6 +83,11 @@ protected function setUp(): void
81
83
/**
82
84
* storeConfig query is cached.
83
85
*
86
+ * Test stores set up:
87
+ * STORE - WEBSITE - STORE GROUP
88
+ * default - base - main_website_store
89
+ * test - base - main_website_store
90
+ *
84
91
* @magentoConfigFixture default/system/full_page_cache/caching_application 2
85
92
* @magentoApiDataFixture Magento/Store/_files/store.php
86
93
* @throws NoSuchEntityException
@@ -152,6 +159,11 @@ public function testGetStoreConfig(): void
152
159
/**
153
160
* Store scoped config change triggers purging only the cache of the changed store.
154
161
*
162
+ * Test stores set up:
163
+ * STORE - WEBSITE - STORE GROUP
164
+ * default - base - main_website_store
165
+ * test - base - main_website_store
166
+ *
155
167
* @magentoConfigFixture default/system/full_page_cache/caching_application 2
156
168
* @magentoApiDataFixture Magento/Store/_files/store.php
157
169
* @throws NoSuchEntityException
@@ -244,6 +256,11 @@ public function testCachePurgedWithStoreScopeConfigChange(): void
244
256
/**
245
257
* Store change triggers purging only the cache of the changed store.
246
258
*
259
+ * Test stores set up:
260
+ * STORE - WEBSITE - STORE GROUP
261
+ * default - base - main_website_store
262
+ * test - base - main_website_store
263
+ *
247
264
* @magentoConfigFixture default/system/full_page_cache/caching_application 2
248
265
* @magentoApiDataFixture Magento/Store/_files/store.php
249
266
* @throws NoSuchEntityException
@@ -341,9 +358,16 @@ public function testCachePurgedWithStoreChange(): void
341
358
/**
342
359
* Store group change triggers purging only the cache of the stores associated with the changed store group.
343
360
*
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
+ *
344
367
* @magentoConfigFixture default/system/full_page_cache/caching_application 2
345
368
* @magentoApiDataFixture Magento/Store/_files/multiple_websites_with_store_groups_stores.php
346
369
* @throws NoSuchEntityException
370
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
347
371
*/
348
372
public function testCachePurgedWithStoreGroupChange (): void
349
373
{
@@ -352,7 +376,6 @@ public function testCachePurgedWithStoreGroupChange(): void
352
376
353
377
// Query default store config
354
378
$ responseDefaultStore = $ this ->graphQlQueryWithResponseHeaders ($ query );
355
- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseDefaultStore ['headers ' ]);
356
379
$ defaultStoreCacheId = $ responseDefaultStore ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
357
380
// Verify we obtain a cache MISS at the 1st time
358
381
$ this ->assertCacheMissAndReturnResponse (
@@ -368,9 +391,7 @@ public function testCachePurgedWithStoreGroupChange(): void
368
391
'' ,
369
392
['Store ' => $ secondStoreCode ]
370
393
);
371
- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseThirdStore ['headers ' ]);
372
394
$ secondStoreCacheId = $ responseThirdStore ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
373
- $ this ->assertNotEquals ($ secondStoreCacheId , $ defaultStoreCacheId );
374
395
// Verify we obtain a cache MISS at the 1st time
375
396
$ secondStoreResponse = $ this ->assertCacheMissAndReturnResponse (
376
397
$ query ,
@@ -379,10 +400,8 @@ public function testCachePurgedWithStoreGroupChange(): void
379
400
'Store ' => $ secondStoreCode
380
401
]
381
402
);
382
- $ this ->assertArrayHasKey ('storeConfig ' , $ secondStoreResponse ['body ' ]);
383
- $ secondStoreResponseResult = $ secondStoreResponse ['body ' ]['storeConfig ' ];
384
403
$ secondStoreGroupName = 'Second store group ' ;
385
- $ this ->assertEquals ($ secondStoreGroupName , $ secondStoreResponseResult ['store_group_name ' ]);
404
+ $ this ->assertEquals ($ secondStoreGroupName , $ secondStoreResponse [ ' body ' ][ ' storeConfig ' ] ['store_group_name ' ]);
386
405
387
406
// Query third store config
388
407
$ thirdStoreCode = 'third_store_view ' ;
@@ -392,7 +411,6 @@ public function testCachePurgedWithStoreGroupChange(): void
392
411
'' ,
393
412
['Store ' => $ thirdStoreCode ]
394
413
);
395
- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseThirdStore ['headers ' ]);
396
414
$ thirdStoreCacheId = $ responseThirdStore ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
397
415
// Verify we obtain a cache MISS at the 1st time
398
416
$ thirdStoreResponse = $ this ->assertCacheMissAndReturnResponse (
@@ -402,9 +420,7 @@ public function testCachePurgedWithStoreGroupChange(): void
402
420
'Store ' => $ thirdStoreCode
403
421
]
404
422
);
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 ' ]);
408
424
409
425
// Change store group name
410
426
/** @var Group $storeGroup */
@@ -430,9 +446,10 @@ public function testCachePurgedWithStoreGroupChange(): void
430
446
'Store ' => $ secondStoreCode
431
447
]
432
448
);
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
+ );
436
453
// Verify we obtain a cache HIT at the 3rd time
437
454
$ this ->assertCacheHitAndReturnResponse (
438
455
$ query ,
@@ -451,9 +468,10 @@ public function testCachePurgedWithStoreGroupChange(): void
451
468
'Store ' => $ thirdStoreCode
452
469
]
453
470
);
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
+ );
457
475
// Verify we obtain a cache HIT at the 3rd time
458
476
$ this ->assertCacheHitAndReturnResponse (
459
477
$ query ,
0 commit comments