1313use Magento \Framework \Api \SearchCriteriaBuilder ;
1414use Magento \Framework \App \Cache \Frontend \Factory as CacheFrontendFactory ;
1515use Magento \Framework \App \Cache \StateInterface as CacheState ;
16- use Magento \Framework \ObjectManagerInterface ;
17- use Magento \GraphQlCache \Model \Cache \Query \Resolver \Result \Type as GraphQlCache ;
16+ use Magento \GraphQlCache \Model \Cache \Query \Resolver \Result \Type as GraphQlResolverCache ;
1817use Magento \GraphQlCache \Model \CacheId \CacheIdCalculator ;
1918use Magento \Integration \Api \CustomerTokenServiceInterface ;
2019use Magento \Store \Model \StoreManagerInterface ;
2827class PageTest extends GraphQlAbstract
2928{
3029 /**
31- * @var ObjectManagerInterface
30+ * @var GraphQlResolverCache
3231 */
33- private $ objectManager ;
34-
35- /**
36- * @var GraphQlCache
37- */
38- private $ graphqlCache ;
32+ private $ graphQlResolverCache ;
3933
4034 /**
4135 * @var PageRepository
@@ -69,25 +63,25 @@ class PageTest extends GraphQlAbstract
6963
7064 protected function setUp (): void
7165 {
72- $ this -> objectManager = $ objectManager = ObjectManager::getInstance ();
66+ $ objectManager = ObjectManager::getInstance ();
7367
74- $ this ->graphqlCache = $ objectManager ->get (GraphQlCache ::class);
68+ $ this ->graphQlResolverCache = $ objectManager ->get (GraphQlResolverCache ::class);
7569 $ this ->pageRepository = $ objectManager ->get (PageRepository::class);
7670 $ this ->searchCriteriaBuilder = $ objectManager ->get (SearchCriteriaBuilder::class);
7771 $ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
7872 $ this ->storeManager = $ objectManager ->get (StoreManagerInterface::class);
7973
8074 $ this ->cacheState = $ objectManager ->get (CacheState::class);
81- $ this ->originalCacheStateEnabledStatus = $ this ->cacheState ->isEnabled (GraphQlCache ::TYPE_IDENTIFIER );
82- $ this ->cacheState ->setEnabled (GraphQlCache ::TYPE_IDENTIFIER , true );
75+ $ this ->originalCacheStateEnabledStatus = $ this ->cacheState ->isEnabled (GraphQlResolverCache ::TYPE_IDENTIFIER );
76+ $ this ->cacheState ->setEnabled (GraphQlResolverCache ::TYPE_IDENTIFIER , true );
8377 }
8478
8579 protected function tearDown (): void
8680 {
8781 // clean graphql resolver cache and reset to original enablement status
88- $ this ->graphqlCache ->clean ();
82+ $ this ->graphQlResolverCache ->clean ();
8983 $ this ->cacheState ->setEnabled (
90- GraphQlCache ::TYPE_IDENTIFIER ,
84+ GraphQlResolverCache ::TYPE_IDENTIFIER ,
9185 $ this ->originalCacheStateEnabledStatus
9286 );
9387
@@ -108,7 +102,7 @@ public function testCmsPageResolverCacheAndInvalidationAsGuest()
108102
109103 $ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page );
110104
111- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
105+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
112106 $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
113107
114108 $ this ->assertEqualsCanonicalizing (
@@ -123,7 +117,7 @@ public function testCmsPageResolverCacheAndInvalidationAsGuest()
123117 $ this ->pageRepository ->save ($ page );
124118
125119 $ this ->assertFalse (
126- $ this ->graphqlCache ->test ($ cacheIdentityString ),
120+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
127121 'Cache entry still exists for CMS page '
128122 );
129123 }
@@ -154,7 +148,7 @@ public function testCmsPageResolverCacheAndInvalidationAsCustomer()
154148
155149 $ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page );
156150
157- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
151+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
158152 $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
159153
160154 $ this ->assertEqualsCanonicalizing (
@@ -169,7 +163,7 @@ public function testCmsPageResolverCacheAndInvalidationAsCustomer()
169163 $ this ->pageRepository ->save ($ page );
170164
171165 $ this ->assertFalse (
172- $ this ->graphqlCache ->test ($ cacheIdentityString ),
166+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString ),
173167 'Cache entry still exists for CMS page '
174168 );
175169 }
@@ -192,7 +186,7 @@ public function testCmsPageResolverCacheWithPostRequest()
192186
193187 $ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page );
194188
195- $ cacheEntry = $ this ->graphqlCache ->load ($ cacheIdentityString );
189+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ cacheIdentityString );
196190 $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
197191
198192 $ this ->assertEqualsCanonicalizing (
@@ -227,7 +221,7 @@ public function testCmsPageResolverCacheGeneratesSeparateEntriesBasedOnArguments
227221
228222 $ resolverCacheKeyForGuestQuery = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page );
229223
230- $ cacheEntry = $ this ->graphqlCache ->load ($ resolverCacheKeyForGuestQuery );
224+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ resolverCacheKeyForGuestQuery );
231225 $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
232226
233227 $ this ->assertEqualsCanonicalizing (
@@ -250,7 +244,7 @@ public function testCmsPageResolverCacheGeneratesSeparateEntriesBasedOnArguments
250244
251245 $ resolverCacheKeyForUserQuery = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page );
252246
253- $ cacheEntry = $ this ->graphqlCache ->load ($ resolverCacheKeyForUserQuery );
247+ $ cacheEntry = $ this ->graphQlResolverCache ->load ($ resolverCacheKeyForUserQuery );
254248 $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
255249
256250 $ this ->assertEqualsCanonicalizing (
@@ -267,7 +261,7 @@ public function testCmsPageResolverCacheGeneratesSeparateEntriesBasedOnArguments
267261 $ this ->assertCount (count ($ resolverCacheKeys ), array_unique ($ resolverCacheKeys ));
268262
269263 foreach ($ resolverCacheKeys as $ cacheIdentityString ) {
270- $ this ->assertNotFalse ($ this ->graphqlCache ->load ($ cacheIdentityString ));
264+ $ this ->assertNotFalse ($ this ->graphQlResolverCache ->load ($ cacheIdentityString ));
271265 }
272266
273267 // invalidate first page and assert first two cache identities (guest and user) are invalidated,
@@ -278,11 +272,11 @@ public function testCmsPageResolverCacheGeneratesSeparateEntriesBasedOnArguments
278272
279273 list ($ page1GuestKey , $ page1UserKey , $ page2GuestKey , $ page2UserKey ) = $ resolverCacheKeys ;
280274
281- $ this ->assertFalse ($ this ->graphqlCache ->load ($ page1GuestKey ));
282- $ this ->assertFalse ($ this ->graphqlCache ->load ($ page1UserKey ));
275+ $ this ->assertFalse ($ this ->graphQlResolverCache ->load ($ page1GuestKey ));
276+ $ this ->assertFalse ($ this ->graphQlResolverCache ->load ($ page1UserKey ));
283277
284- $ this ->assertNotFalse ($ this ->graphqlCache ->load ($ page2GuestKey ));
285- $ this ->assertNotFalse ($ this ->graphqlCache ->load ($ page2UserKey ));
278+ $ this ->assertNotFalse ($ this ->graphQlResolverCache ->load ($ page2GuestKey ));
279+ $ this ->assertNotFalse ($ this ->graphQlResolverCache ->load ($ page2UserKey ));
286280 }
287281
288282 /**
@@ -302,7 +296,7 @@ public function testCmsPageResolverCacheInvalidatesWhenPageGetsDeleted()
302296 $ cacheIdentityStringPage1 = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page1 );
303297
304298 $ this ->assertIsNumeric (
305- $ this ->graphqlCache ->test ($ cacheIdentityStringPage1 )
299+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage1 )
306300 );
307301
308302 // cache page2
@@ -314,20 +308,20 @@ public function testCmsPageResolverCacheInvalidatesWhenPageGetsDeleted()
314308 $ cacheIdentityStringPage2 = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page2 );
315309
316310 $ this ->assertIsNumeric (
317- $ this ->graphqlCache ->test ($ cacheIdentityStringPage2 )
311+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage2 )
318312 );
319313
320314 // delete page1 and assert cache is invalidated
321315 $ this ->pageRepository ->delete ($ page1 );
322316
323317 $ this ->assertFalse (
324- $ this ->graphqlCache ->test ($ cacheIdentityStringPage1 ),
318+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage1 ),
325319 'Cache entry still exists for deleted CMS page '
326320 );
327321
328322 // assert page2 cache entry still exists
329323 $ this ->assertIsNumeric (
330- $ this ->graphqlCache ->test ($ cacheIdentityStringPage2 )
324+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage2 )
331325 );
332326 }
333327
@@ -347,7 +341,7 @@ public function testCmsPageResolverCacheInvalidatesWhenPageGetsDisabled()
347341 $ cacheIdentityStringPage1 = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page1 );
348342
349343 $ this ->assertIsNumeric (
350- $ this ->graphqlCache ->test ($ cacheIdentityStringPage1 )
344+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage1 )
351345 );
352346
353347 // cache page2
@@ -359,21 +353,21 @@ public function testCmsPageResolverCacheInvalidatesWhenPageGetsDisabled()
359353 $ cacheIdentityStringPage2 = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ page2 );
360354
361355 $ this ->assertIsNumeric (
362- $ this ->graphqlCache ->test ($ cacheIdentityStringPage2 )
356+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage2 )
363357 );
364358
365359 // disable page 1
366360 $ page1 ->setIsActive (false );
367361 $ this ->pageRepository ->save ($ page1 );
368362
369363 $ this ->assertFalse (
370- $ this ->graphqlCache ->test ($ cacheIdentityStringPage1 ),
364+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage1 ),
371365 'Cache entry still exists for disabled CMS page '
372366 );
373367
374368 // assert page2 cache entry still exists
375369 $ this ->assertIsNumeric (
376- $ this ->graphqlCache ->test ($ cacheIdentityStringPage2 )
370+ $ this ->graphQlResolverCache ->test ($ cacheIdentityStringPage2 )
377371 );
378372 }
379373
@@ -401,7 +395,7 @@ public function testCmsPageResolverCacheDoesNotSaveNonExistentCmsPage()
401395 $ cacheIdentityString = $ this ->getResolverCacheKeyFromResponseAndPage ($ response , $ nonExistentPage );
402396
403397 $ this ->assertFalse (
404- $ this ->graphqlCache ->load ($ cacheIdentityString )
398+ $ this ->graphQlResolverCache ->load ($ cacheIdentityString )
405399 );
406400 }
407401
@@ -429,7 +423,7 @@ public function testCmsResolverCacheIsInvalidatedAfterChangingItsStoreView()
429423 );
430424
431425 $ this ->assertIsNumeric (
432- $ this ->graphqlCache ->test ($ cacheIdentityString )
426+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString )
433427 );
434428
435429 // change store id of page
@@ -439,7 +433,7 @@ public function testCmsResolverCacheIsInvalidatedAfterChangingItsStoreView()
439433
440434 // assert cache entry is invalidated
441435 $ this ->assertFalse (
442- $ this ->graphqlCache ->test ($ cacheIdentityString )
436+ $ this ->graphQlResolverCache ->test ($ cacheIdentityString )
443437 );
444438 }
445439
@@ -462,7 +456,7 @@ public function testCacheExpirationTimeUsesDefaultDirective()
462456 $ page
463457 );
464458
465- $ lowLevelFrontendCache = $ this ->graphqlCache ->getLowLevelFrontend ();
459+ $ lowLevelFrontendCache = $ this ->graphQlResolverCache ->getLowLevelFrontend ();
466460 $ metadatas = $ lowLevelFrontendCache ->getMetadatas ($ cacheIdentityString );
467461
468462 $ this ->assertEquals (
@@ -489,15 +483,15 @@ private function generateExpectedDataFromPage(PageInterface $page): array
489483
490484 private function assertTagsByCacheIdentityAndPage (string $ cacheIdentityString , PageInterface $ page ): void
491485 {
492- $ lowLevelFrontendCache = $ this ->graphqlCache ->getLowLevelFrontend ();
486+ $ lowLevelFrontendCache = $ this ->graphQlResolverCache ->getLowLevelFrontend ();
493487 $ cacheIdPrefix = $ lowLevelFrontendCache ->getOption ('cache_id_prefix ' );
494488 $ metadatas = $ lowLevelFrontendCache ->getMetadatas ($ cacheIdentityString );
495489 $ tags = $ metadatas ['tags ' ];
496490
497491 $ this ->assertEqualsCanonicalizing (
498492 [
499493 $ cacheIdPrefix . strtoupper (CmsPage::CACHE_TAG ) . '_ ' . $ page ->getId (),
500- $ cacheIdPrefix . strtoupper (GraphQlCache ::CACHE_TAG ),
494+ $ cacheIdPrefix . strtoupper (GraphQlResolverCache ::CACHE_TAG ),
501495 $ cacheIdPrefix . 'MAGE ' ,
502496 ],
503497 $ tags
@@ -538,7 +532,7 @@ private function getResolverCacheKeyFromResponseAndPage(array $response, PageInt
538532 ]));
539533
540534 $ cacheIdParts = [
541- GraphQlCache ::CACHE_TAG ,
535+ GraphQlResolverCache ::CACHE_TAG ,
542536 $ cacheIdValue ,
543537 sha1 ($ cacheIdQueryPayloadMetadata )
544538 ];
0 commit comments