10
10
use Magento \Cms \Api \BlockRepositoryInterface ;
11
11
use Magento \Cms \Api \Data \BlockInterface ;
12
12
use Magento \Cms \Model \Block ;
13
- use Magento \GraphQlCache \Model \Cache \Query \Resolver \Result \Type as GraphQlCache ;
13
+ use Magento \GraphQlCache \Model \Cache \Query \Resolver \Result \Type as GraphQlResolverCache ;
14
14
use Magento \GraphQlCache \Model \CacheId \CacheIdCalculator ;
15
15
use Magento \Store \Model \StoreManagerInterface ;
16
16
use Magento \TestFramework \ObjectManager ;
@@ -26,9 +26,9 @@ class BlockTest extends GraphQlAbstract
26
26
private $ blockRepository ;
27
27
28
28
/**
29
- * @var GraphQlCache
29
+ * @var GraphQlResolverCache
30
30
*/
31
- private $ graphqlCache ;
31
+ private $ graphQlResolverCache ;
32
32
33
33
/**
34
34
* @var FilterEmulate
@@ -44,14 +44,14 @@ protected function setUp(): void
44
44
{
45
45
$ objectManager = ObjectManager::getInstance ();
46
46
$ this ->blockRepository = $ objectManager ->get (BlockRepositoryInterface::class);
47
- $ this ->graphqlCache = $ objectManager ->get (GraphQlCache ::class);
47
+ $ this ->graphQlResolverCache = $ objectManager ->get (GraphQlResolverCache ::class);
48
48
$ this ->widgetFilter = $ objectManager ->get (FilterEmulate::class);
49
49
$ this ->storeManager = $ objectManager ->get (StoreManagerInterface::class);
50
50
}
51
51
52
52
protected function tearDown (): void
53
53
{
54
- $ this ->graphqlCache ->clean ();
54
+ $ this ->graphQlResolverCache ->clean ();
55
55
56
56
parent ::tearDown ();
57
57
}
@@ -71,7 +71,7 @@ public function testCmsSingleBlockResolverCacheAndInvalidationAsGuest()
71
71
72
72
$ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ block ]);
73
73
74
- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
74
+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
75
75
$ cacheEntryDecoded = json_decode ($ cacheEntry , true );
76
76
77
77
$ this ->assertEqualsCanonicalizing (
@@ -89,7 +89,7 @@ public function testCmsSingleBlockResolverCacheAndInvalidationAsGuest()
89
89
$ this ->blockRepository ->save ($ block );
90
90
91
91
$ this ->assertFalse (
92
- $ this ->graphqlCache ->test ($ cacheIdentityString ),
92
+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
93
93
'Cache entry should be invalidated after block content change '
94
94
);
95
95
}
@@ -115,7 +115,7 @@ public function testCmsMultipleBlockResolverCacheAndInvalidationAsGuest()
115
115
$ block2 ,
116
116
]);
117
117
118
- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
118
+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
119
119
$ cacheEntryDecoded = json_decode ($ cacheEntry , true );
120
120
121
121
$ this ->assertEqualsCanonicalizing (
@@ -133,7 +133,7 @@ public function testCmsMultipleBlockResolverCacheAndInvalidationAsGuest()
133
133
$ this ->blockRepository ->save ($ block2 );
134
134
135
135
$ this ->assertFalse (
136
- $ this ->graphqlCache ->test ($ cacheIdentityString ),
136
+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
137
137
'Cache entry should be invalidated after block content change '
138
138
);
139
139
}
@@ -153,7 +153,7 @@ public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDeleted()
153
153
154
154
$ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ block ]);
155
155
156
- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
156
+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
157
157
$ cacheEntryDecoded = json_decode ($ cacheEntry , true );
158
158
159
159
$ this ->assertEqualsCanonicalizing (
@@ -170,7 +170,7 @@ public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDeleted()
170
170
$ this ->blockRepository ->delete ($ block );
171
171
172
172
$ this ->assertFalse (
173
- $ this ->graphqlCache ->test ($ cacheIdentityString ),
173
+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
174
174
'Cache entry should be invalidated after block deletion '
175
175
);
176
176
}
@@ -190,7 +190,7 @@ public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDisabled()
190
190
191
191
$ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ block ]);
192
192
193
- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
193
+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
194
194
$ cacheEntryDecoded = json_decode ($ cacheEntry , true );
195
195
196
196
$ this ->assertEqualsCanonicalizing (
@@ -208,7 +208,7 @@ public function testCmsBlockResolverCacheInvalidatesWhenBlockGetsDisabled()
208
208
$ this ->blockRepository ->save ($ block );
209
209
210
210
$ this ->assertFalse (
211
- $ this ->graphqlCache ->test ($ cacheIdentityString ),
211
+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
212
212
'Cache entry should be invalidated after block disablement '
213
213
);
214
214
}
@@ -230,7 +230,7 @@ public function testCmsBlockResolverCacheIsInvalidatedAfterChangingItsStoreView(
230
230
231
231
$ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ block ]);
232
232
233
- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
233
+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
234
234
$ cacheEntryDecoded = json_decode ($ cacheEntry , true );
235
235
236
236
$ this ->assertEqualsCanonicalizing (
@@ -249,7 +249,7 @@ public function testCmsBlockResolverCacheIsInvalidatedAfterChangingItsStoreView(
249
249
$ this ->blockRepository ->save ($ block );
250
250
251
251
$ this ->assertFalse (
252
- $ this ->graphqlCache ->test ($ cacheIdentityString ),
252
+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
253
253
'Cache entry should be invalidated after changing block \'s store view '
254
254
);
255
255
}
@@ -279,7 +279,7 @@ public function testCmsBlockResolverCacheDoesNotSaveNonExistentCmsBlock()
279
279
$ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndBlocks ($ response , [$ nonExistentBlock ]);
280
280
281
281
$ this ->assertFalse (
282
- $ this ->graphqlCache ->load ($ cacheIdentityString )
282
+ $ this ->graphQlResolverCache ->load ($ cacheIdentityString )
283
283
);
284
284
}
285
285
@@ -341,14 +341,14 @@ private function generateExpectedDataFromBlocks(array $blocks): array
341
341
*/
342
342
private function assertTagsByCacheIdentityAndBlocks (string $ cacheIdentityString , array $ blocks ): void
343
343
{
344
- $ lowLevelFrontendCache = $ this ->graphqlCache ->getLowLevelFrontend ();
344
+ $ lowLevelFrontendCache = $ this ->graphQlResolverCache ->getLowLevelFrontend ();
345
345
$ cacheIdPrefix = $ lowLevelFrontendCache ->getOption ('cache_id_prefix ' );
346
346
$ metadatas = $ lowLevelFrontendCache ->getMetadatas ($ cacheIdentityString );
347
347
$ tags = $ metadatas ['tags ' ];
348
348
349
349
$ expectedTags = [
350
350
$ cacheIdPrefix . strtoupper (Block::CACHE_TAG ),
351
- $ cacheIdPrefix . strtoupper (GraphQlCache ::CACHE_TAG ),
351
+ $ cacheIdPrefix . strtoupper (GraphQlResolverCache ::CACHE_TAG ),
352
352
$ cacheIdPrefix . 'MAGE ' ,
353
353
];
354
354
@@ -376,16 +376,12 @@ private function getResolverCacheKeyFromResponseAndBlocks(array $response, array
376
376
return $ block ->getIdentifier ();
377
377
}, $ blocks );
378
378
379
- print_r ($ this ->getBlockIdentifiersListAsString ($ blockIdentifiers ));
380
-
381
379
$ cacheIdQueryPayloadMetadata = sprintf ('CmsBlocks%s ' , json_encode ([
382
380
'identifiers ' => $ blockIdentifiers ,
383
381
]));
384
382
385
- echo $ cacheIdQueryPayloadMetadata , PHP_EOL ;
386
-
387
383
$ cacheIdParts = [
388
- GraphQlCache ::CACHE_TAG ,
384
+ GraphQlResolverCache ::CACHE_TAG ,
389
385
$ cacheIdValue ,
390
386
sha1 ($ cacheIdQueryPayloadMetadata )
391
387
];
0 commit comments