@@ -45,9 +45,10 @@ public function testCacheIsUsedOnSecondRequest()
45
45
46
46
$ query = $ this ->getPageQuery ($ pageId );
47
47
48
- // Obtain the X-Magento-Cache-Id from the response which will be used as the cache key
48
+
49
49
$ response = $ this ->graphQlQueryWithResponseHeaders ($ query );
50
50
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ response ['headers ' ]);
51
+ // Obtain the X-Magento-Cache-Id from the response which will be used as the cache key
51
52
$ cacheId = $ response ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
52
53
// Verify we obtain a cache MISS the first time
53
54
$ this ->assertCacheMissAndReturnResponse ($ query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
@@ -101,37 +102,44 @@ public function testCacheIsInvalidatedOnPageUpdate()
101
102
[CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdPageBlankResponse ]
102
103
);
103
104
104
- //cache-debug should be a HIT on second request
105
+ //cache-debug should be a HIT on second request for page100 query
105
106
$ this ->assertCacheHitAndReturnResponse (
106
107
$ page100Query ,
107
108
[CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdPage100Response ]
108
109
);
109
- //cache-debug should be a HIT on second request
110
+ //cache-debug should be a HIT on second request for page blank query
110
111
$ this ->assertCacheHitAndReturnResponse (
111
112
$ pageBlankQuery ,
112
113
[CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdPageBlankResponse ]
113
114
);
114
115
116
+ //cache-debug should be a MISS after updating the blank page
115
117
$ pageRepository = Bootstrap::getObjectManager ()->get (PageRepository::class);
116
118
$ newPageContent = 'New page content for blank page. ' ;
117
119
$ pageBlank ->setContent ($ newPageContent );
118
120
$ pageRepository ->save ($ pageBlank );
119
121
120
- //cache-debug should be a MISS after updating the page
122
+
121
123
$ pageBlankResponseMissAfterUpdate = $ this ->graphQlQueryWithResponseHeaders ($ pageBlankQuery );
122
- // Verify we obtain a cache MISS after updating the page
124
+ // Verify we obtain a cache MISS after updating the page blank query
123
125
$ this ->assertCacheMissAndReturnResponse (
124
126
$ pageBlankQuery ,
125
127
[CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdPageBlankResponse ]
126
128
);
127
129
130
+ $ pageBlankResponseHitAfterUpdate = $ this ->assertCacheHitAndReturnResponse (
131
+ $ pageBlankQuery ,
132
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdPageBlankResponse ]
133
+ );
134
+
135
+ // Verify we obtain a cache Hit after updating the page on page 100 query
128
136
$ this ->assertCacheHitAndReturnResponse (
129
137
$ page100Query ,
130
138
[CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdPage100Response ]
131
139
);
132
140
133
- //updated page data should be correct
134
- $ this ->assertNotEmpty ($ pageBlankResponseMissAfterUpdate ['body ' ]);
141
+ //updated page data should be correct for blank page
142
+ $ this ->assertNotEmpty ($ pageBlankResponseHitAfterUpdate ['body ' ]);
135
143
$ pageData = $ pageBlankResponseMissAfterUpdate ['body ' ]['cmsPage ' ];
136
144
$ this ->assertArrayNotHasKey ('errors ' , $ pageBlankResponseMissAfterUpdate ['body ' ]);
137
145
$ this ->assertEquals ('Cms Page Design Blank ' , $ pageData ['title ' ]);
0 commit comments