@@ -39,7 +39,7 @@ public function testCacheInvalidationForProducts()
39
39
}
40
40
}
41
41
QUERY ;
42
- // Cache-debug should be a MISS when product is queried for first time
42
+ // Cache should be a MISS when product is queried for first time
43
43
// Obtain the X-Magento-Cache-Id from the response which will be used as the cache key
44
44
$ response = $ this ->graphQlQueryWithResponseHeaders ($ query );
45
45
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ response ['headers ' ]);
@@ -59,7 +59,7 @@ public function testCacheInvalidationForProducts()
59
59
$ responseAfterUpdate = $ this ->graphQlQueryWithResponseHeaders ($ query );
60
60
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseAfterUpdate ['headers ' ]);
61
61
$ cacheId = $ responseAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
62
- // Cache invalidation happens and cache-debug header value is a MISS after product update
62
+ // Cache invalidation happens and cache header value is a MISS after product update
63
63
$ this ->assertCacheMissAndReturnResponse ($ query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
64
64
}
65
65
@@ -95,30 +95,32 @@ public function testCacheInvalidationForCategoriesWithProduct()
95
95
$ cacheId = $ responseFirstProduct ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
96
96
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
97
97
$ this ->assertCacheMissAndReturnResponse ($ product1Query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
98
- // Verify we obtain a cache HIT the second time around for this X-Magento-Cache-Id
99
- $ this ->assertCacheHitAndReturnResponse ($ product1Query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
98
+
99
+ // Cache-debug header should be a MISS for product 2 during first load
100
+ $ responseMissSecondProduct = $ this ->graphQlQueryWithResponseHeaders ($ product2Query );
101
+ $ cacheId = $ responseMissSecondProduct ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
102
+ // Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
103
+ $ this ->assertCacheMissAndReturnResponse ($ product2Query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
100
104
101
105
$ firstProduct ->setPrice (20 );
102
106
$ productRepository ->save ($ firstProduct );
103
107
104
108
// cache-debug header value should be MISS after updating product1 and reloading the Category
105
- $ responseMissCategoryAfterUpdate = $ this ->graphQlQueryWithResponseHeaders ($ categoryQuery );
106
- $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseMissCategoryAfterUpdate ['headers ' ]);
107
- $ cacheId = $ responseMissCategoryAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
109
+ $ responseMissCategoryAfterProductUpdate = $ this ->graphQlQueryWithResponseHeaders ($ categoryQuery );
110
+ $ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ responseMissCategoryAfterProductUpdate ['headers ' ]);
111
+ $ cacheId = $ responseMissCategoryAfterProductUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
108
112
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
109
113
$ this ->assertCacheMissAndReturnResponse ($ categoryQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
110
114
111
115
// cache-debug should be a MISS for product 1 after it is updated - cache invalidation
112
- $ responseMissFirstProductAfterUpdate = $ this ->graphQlQueryWithResponseHeaders ($ product1Query );
113
- $ cacheId = $ responseMissFirstProductAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
116
+ $ responseMissFirstProductAfterProductUpdate = $ this ->graphQlQueryWithResponseHeaders ($ product1Query );
117
+ $ cacheId = $ responseMissFirstProductAfterProductUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
114
118
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
115
119
$ this ->assertCacheMissAndReturnResponse ($ product1Query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
116
120
117
- // Cache-debug header responses for product 2
121
+ // Cache-debug header responses for product 2 and should be a HIT for product 2
118
122
$ responseHitSecondProduct = $ this ->graphQlQueryWithResponseHeaders ($ product2Query );
119
123
$ cacheId = $ responseHitSecondProduct ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
120
- // Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
121
- $ this ->assertCacheMissAndReturnResponse ($ product2Query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
122
124
// Verify we obtain a cache HIT the second time around for this X-Magento-Cache-Id
123
125
$ this ->assertCacheHitAndReturnResponse ($ product2Query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
124
126
}
@@ -156,7 +158,6 @@ private function getCategoryQuery(): string
156
158
$ categoryId = 4 ;
157
159
$ pageSize = 10 ;
158
160
$ currentPage = 1 ;
159
-
160
161
$ categoryQueryString = <<<QUERY
161
162
query {
162
163
category(id: $ categoryId) {
0 commit comments