@@ -36,15 +36,15 @@ public function testCacheIsUsedOnSecondRequest()
36
36
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
37
37
$ this ->assertCacheMissAndReturnResponse ($ query , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
38
38
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
39
- $ responseAfterUpdate = $ this ->assertCacheHitAndReturnResponse (
39
+ $ responseHit = $ this ->assertCacheHitAndReturnResponse (
40
40
$ query ,
41
41
[CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]
42
42
);
43
43
44
44
//cached data should be correct
45
- $ this ->assertNotEmpty ($ responseAfterUpdate ['body ' ]);
46
- $ this ->assertArrayNotHasKey ('errors ' , $ responseAfterUpdate ['body ' ]);
47
- $ blocks = $ responseAfterUpdate ['body ' ]['cmsBlocks ' ]['items ' ];
45
+ $ this ->assertNotEmpty ($ responseHit ['body ' ]);
46
+ $ this ->assertArrayNotHasKey ('errors ' , $ responseHit ['body ' ]);
47
+ $ blocks = $ responseHit ['body ' ]['cmsBlocks ' ]['items ' ];
48
48
$ this ->assertEquals ($ blockIdentifier , $ blocks [0 ]['identifier ' ]);
49
49
$ this ->assertEquals ('CMS Block Title ' , $ blocks [0 ]['title ' ]);
50
50
}
@@ -66,43 +66,61 @@ public function testCacheIsInvalidatedOnBlockUpdate()
66
66
//cache-debug should be a MISS on first request and HIT on second request
67
67
$ fixtureBlock = $ this ->graphQlQueryWithResponseHeaders ($ fixtureBlockQuery );
68
68
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ fixtureBlock ['headers ' ]);
69
- $ cacheId = $ fixtureBlock ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
69
+ $ cacheIdOfFixtureBlock = $ fixtureBlock ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
70
70
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
71
- $ this ->assertCacheMissAndReturnResponse ($ fixtureBlockQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
71
+ $ this ->assertCacheMissAndReturnResponse (
72
+ $ fixtureBlockQuery ,
73
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdOfFixtureBlock ]
74
+ );
72
75
73
76
$ enabledBlock = $ this ->graphQlQueryWithResponseHeaders ($ enabledBlockQuery );
74
77
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ enabledBlock ['headers ' ]);
75
- $ cacheId = $ enabledBlock ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
78
+ $ cacheIdOfEnabledBlock = $ enabledBlock ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
76
79
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
77
- $ this ->assertCacheMissAndReturnResponse ($ enabledBlockQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
80
+ $ this ->assertCacheMissAndReturnResponse (
81
+ $ enabledBlockQuery ,
82
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdOfEnabledBlock ]
83
+ );
78
84
79
85
//cache should be a HIT on second request
80
86
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
81
- $ this ->assertCacheHitAndReturnResponse ($ fixtureBlockQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
87
+ $ this ->assertCacheHitAndReturnResponse (
88
+ $ fixtureBlockQuery ,
89
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdOfFixtureBlock ]
90
+ );
82
91
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
83
- $ this ->assertCacheHitAndReturnResponse ($ enabledBlockQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
92
+ $ this ->assertCacheHitAndReturnResponse (
93
+ $ enabledBlockQuery ,
94
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdOfEnabledBlock ]
95
+ );
84
96
85
97
$ newBlockContent = 'New block content!!! ' ;
86
98
$ this ->updateBlockContent ($ fixtureBlockIdentifier , $ newBlockContent );
87
99
88
100
//cache-debug should be a MISS after update the block on fixture block query
89
101
$ fixtureBlockAfterUpdate = $ this ->graphQlQueryWithResponseHeaders ($ fixtureBlockQuery );
90
102
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ fixtureBlock ['headers ' ]);
91
- $ cacheId = $ fixtureBlockAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
103
+ $ cacheIdOfFixtureBlockAfterUpdate = $ fixtureBlockAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
92
104
// Verify we obtain a cache MISS the first time we search the cache using this X-Magento-Cache-Id
93
- $ this ->assertCacheMissAndReturnResponse ($ fixtureBlockQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
105
+ $ fixtureBlockHitResponse = $ this ->assertCacheMissAndReturnResponse (
106
+ $ fixtureBlockQuery ,
107
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdOfFixtureBlockAfterUpdate ]
108
+ );
94
109
95
110
//cache-debug should be a HIT after update the block on enabled block query
96
111
$ enabledBlockAfterUpdate = $ this ->graphQlQueryWithResponseHeaders ($ enabledBlockQuery );
97
112
$ this ->assertArrayHasKey (CacheIdCalculator::CACHE_ID_HEADER , $ enabledBlock ['headers ' ]);
98
- $ cacheId = $ enabledBlockAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
113
+ $ cacheIdOfEnabledBlockAfterUpdate = $ enabledBlockAfterUpdate ['headers ' ][CacheIdCalculator::CACHE_ID_HEADER ];
99
114
// Verify we obtain a cache HIT the second time we search the cache using this X-Magento-Cache-Id
100
- $ this ->assertCacheHitAndReturnResponse ($ enabledBlockQuery , [CacheIdCalculator::CACHE_ID_HEADER => $ cacheId ]);
115
+ $ this ->assertCacheHitAndReturnResponse (
116
+ $ enabledBlockQuery ,
117
+ [CacheIdCalculator::CACHE_ID_HEADER => $ cacheIdOfEnabledBlockAfterUpdate ]
118
+ );
101
119
102
120
//updated block data should be correct on fixture block
103
- $ this ->assertNotEmpty ($ fixtureBlockAfterUpdate ['body ' ]);
104
- $ blocks = $ fixtureBlockAfterUpdate ['body ' ]['cmsBlocks ' ]['items ' ];
105
- $ this ->assertArrayNotHasKey ('errors ' , $ fixtureBlockAfterUpdate ['body ' ]);
121
+ $ this ->assertNotEmpty ($ fixtureBlockHitResponse ['body ' ]);
122
+ $ blocks = $ fixtureBlockHitResponse ['body ' ]['cmsBlocks ' ]['items ' ];
123
+ $ this ->assertArrayNotHasKey ('errors ' , $ fixtureBlockHitResponse ['body ' ]);
106
124
$ this ->assertEquals ($ fixtureBlockIdentifier , $ blocks [0 ]['identifier ' ]);
107
125
$ this ->assertEquals ('CMS Block Title ' , $ blocks [0 ]['title ' ]);
108
126
$ this ->assertEquals ($ newBlockContent , $ blocks [0 ]['content ' ]);
0 commit comments