@@ -299,19 +299,13 @@ public function testCustomerResolverCacheInvalidationOnStoreChange()
299299 * @param CustomerInterface $customer
300300 * @return void
301301 */
302- private static function assertCurrentCustomerCacheRecordExists (CustomerInterface $ customer )
302+ private function assertCurrentCustomerCacheRecordExists (CustomerInterface $ customer )
303303 {
304- $ cacheKey = self ::getCacheKeyForCustomerResolver ();
305-
306- if (is_callable ($ cacheKey [1 ]))
307- {
308- $ cacheKey [1 ] = $ cacheKey [1 ](CustomerTest::class);
309- }
310- $ cacheKey = strtoupper (implode ('_ ' , $ cacheKey ));
304+ $ cacheKey = $ this ->getCacheKeyForCustomerResolver ();
311305 $ cacheEntry = Bootstrap::getObjectManager ()->get (GraphQlResolverCache::class)->load ($ cacheKey );
312306 $ cacheEntryDecoded = json_decode ($ cacheEntry , true );
313307
314- self :: assertEquals (
308+ $ this -> assertEquals (
315309 $ customer ->getEmail (),
316310 $ cacheEntryDecoded ['email ' ]
317311 );
@@ -324,13 +318,7 @@ private static function assertCurrentCustomerCacheRecordExists(CustomerInterface
324318 */
325319 private function assertCurrentCustomerCacheRecordDoesNotExist ()
326320 {
327- $ cacheKey = self ::getCacheKeyForCustomerResolver ();
328-
329- if (is_callable ($ cacheKey [1 ]))
330- {
331- $ cacheKey [1 ] = $ cacheKey [1 ](CustomerTest::class);
332- }
333- $ cacheKey = strtoupper (implode ('_ ' , $ cacheKey ));
321+ $ cacheKey = $ this ->getCacheKeyForCustomerResolver ();
334322 $ this ->assertFalse (
335323 Bootstrap::getObjectManager ()->get (GraphQlResolverCache::class)->test ($ cacheKey )
336324 );
@@ -362,13 +350,7 @@ public function testCustomerResolverCacheGeneratesSeparateEntriesForEachCustomer
362350 ['Authorization ' => 'Bearer ' . $ customer1Token ]
363351 );
364352
365- $ customer1CacheKey = self ::getCacheKeyForCustomerResolver ();
366-
367- if (is_callable ($ customer1CacheKey [1 ]))
368- {
369- $ customer1CacheKey [1 ] = $ customer1CacheKey [1 ]($ this );
370- }
371- $ customer1CacheKey = strtoupper (implode ('_ ' , $ customer1CacheKey ));
353+ $ customer1CacheKey = $ this ->getCacheKeyForCustomerResolver ();
372354
373355 $ this ->assertIsNumeric (
374356 $ this ->graphQlResolverCache ->test ($ customer1CacheKey )
@@ -388,13 +370,7 @@ public function testCustomerResolverCacheGeneratesSeparateEntriesForEachCustomer
388370 ['Authorization ' => 'Bearer ' . $ customer2Token ]
389371 );
390372
391- $ customer2CacheKey = self ::getCacheKeyForCustomerResolver ();
392-
393- if (is_callable ($ customer2CacheKey [1 ]))
394- {
395- $ customer2CacheKey [1 ] = $ customer2CacheKey [1 ]($ this );
396- }
397- $ customer2CacheKey = strtoupper (implode ('_ ' , $ customer2CacheKey ));
373+ $ customer2CacheKey = $ this ->getCacheKeyForCustomerResolver ();
398374
399375 $ this ->assertIsNumeric (
400376 $ this ->graphQlResolverCache ->test ($ customer2CacheKey )
@@ -441,13 +417,7 @@ public function testCustomerResolverCacheInvalidatesWhenCustomerGetsDeleted()
441417 ['Authorization ' => 'Bearer ' . $ token ]
442418 );
443419
444- $ cacheKey = self ::getCacheKeyForCustomerResolver ();
445-
446- if (is_callable ($ cacheKey [1 ]))
447- {
448- $ cacheKey [1 ] = $ cacheKey [1 ]($ this );
449- }
450- $ cacheKey = strtoupper (implode ('_ ' , $ cacheKey ));
420+ $ cacheKey = $ this ->getCacheKeyForCustomerResolver ();
451421
452422 $ this ->assertIsNumeric (
453423 $ this ->graphQlResolverCache ->test ($ cacheKey )
@@ -511,13 +481,7 @@ public function testCustomerWithSameEmailInTwoSeparateWebsitesKeepsSeparateCache
511481 ['Authorization ' => 'Bearer ' . $ customer1Token ]
512482 );
513483
514- $ customer1CacheKey = self ::getCacheKeyForCustomerResolver ();
515-
516- if (is_callable ($ customer1CacheKey [1 ]))
517- {
518- $ customer1CacheKey [1 ] = $ customer1CacheKey [1 ]($ this );
519- }
520- $ customer1CacheKey = strtoupper (implode ('_ ' , $ customer1CacheKey ));
484+ $ customer1CacheKey = $ this ->getCacheKeyForCustomerResolver ();
521485 $ customer1CacheEntry = $ this ->graphQlResolverCache ->load ($ customer1CacheKey );
522486 $ customer1CacheEntryDecoded = json_decode ($ customer1CacheEntry , true );
523487 $ this ->assertEquals (
@@ -543,13 +507,7 @@ public function testCustomerWithSameEmailInTwoSeparateWebsitesKeepsSeparateCache
543507 ]
544508 );
545509
546- $ customer2CacheKey = self ::getCacheKeyForCustomerResolver ();
547-
548- if (is_callable ($ customer2CacheKey [1 ]))
549- {
550- $ customer2CacheKey [1 ] = $ customer2CacheKey [1 ]($ this );
551- }
552- $ customer2CacheKey = strtoupper (implode ('_ ' , $ customer2CacheKey ));
510+ $ customer2CacheKey = $ this ->getCacheKeyForCustomerResolver ();
553511
554512 $ customer2CacheEntry = $ this ->graphQlResolverCache ->load ($ customer2CacheKey );
555513 $ customer2CacheEntryDecoded = json_decode ($ customer2CacheEntry , true );
@@ -588,13 +546,7 @@ public function testGuestQueryingCustomerDoesNotGenerateResolverCacheEntry()
588546 // expected exception
589547 }
590548
591- $ cacheKey = self ::getCacheKeyForCustomerResolver ();
592-
593- if (is_callable ($ cacheKey [1 ]))
594- {
595- $ cacheKey [1 ] = $ cacheKey [1 ]($ this );
596- }
597- $ cacheKey = strtoupper (implode ('_ ' , $ cacheKey ));
549+ $ cacheKey = $ this ->getCacheKeyForCustomerResolver ();
598550
599551 $ this ->assertFalse (
600552 $ this ->graphQlResolverCache ->test ($ cacheKey )
@@ -666,7 +618,7 @@ public function testCustomerQueryingCustomerWithDifferentStoreHeaderDoesNotGener
666618 );
667619 }
668620
669- public static function invalidationMechanismProvider (): array
621+ public function invalidationMechanismProvider (): array
670622 {
671623 // provider is invoked before setUp() is called so need to init here
672624 $ repo = Bootstrap::getObjectManager ()->get (
@@ -689,51 +641,51 @@ function (CustomerInterface $customer) use ($repo) {
689641 'add and delete address ' => [
690642 function (CustomerInterface $ customer , $ tokenString ) {
691643 // create new address because default billing address cannot be deleted
692- self :: graphQlMutation (
693- self :: getCreateAddressMutation ("4000 Polk St " ),
644+ $ this -> graphQlMutation (
645+ $ this -> getCreateAddressMutation ("4000 Polk St " ),
694646 [],
695647 '' ,
696648 ['Authorization ' => 'Bearer ' . $ tokenString ]
697649 );
698650 // query for customer to cache data after address creation
699- $ result = self :: graphQlQuery (
700- self :: getCustomerQuery (),
651+ $ result = $ this -> graphQlQuery (
652+ $ this -> getCustomerQuery (),
701653 [],
702654 '' ,
703655 ['Authorization ' => 'Bearer ' . $ tokenString ]
704656 );
705657 // assert that cache record exists for given customer
706- self :: assertCurrentCustomerCacheRecordExists ($ customer );
658+ $ this -> assertCurrentCustomerCacheRecordExists ($ customer );
707659
708660 $ addressId = $ result ['customer ' ]['addresses ' ][1 ]['id ' ];
709- $ result = self :: graphQlMutation (
710- self :: getDeleteAddressMutation ($ addressId ),
661+ $ result = $ this -> graphQlMutation (
662+ $ this -> getDeleteAddressMutation ($ addressId ),
711663 [],
712664 '' ,
713665 ['Authorization ' => 'Bearer ' . $ tokenString ]
714666 );
715- self :: assertTrue ($ result ['deleteCustomerAddress ' ]);
667+ $ this -> assertTrue ($ result ['deleteCustomerAddress ' ]);
716668 },
717669 ],
718670 'update address ' => [
719671 function (CustomerInterface $ customer , $ tokenString ) {
720672 // query for customer to cache data after address creation
721- $ result = self :: graphQlQuery (
722- self :: getCustomerQuery (),
673+ $ result = $ this -> graphQlQuery (
674+ $ this -> getCustomerQuery (),
723675 [],
724676 '' ,
725677 ['Authorization ' => 'Bearer ' . $ tokenString ]
726678 );
727679
728680 $ addressId = $ result ['customer ' ]['addresses ' ][0 ]['id ' ];
729- $ result = self :: graphQlMutation (
730- self :: getUpdateAddressStreetMutation ($ addressId , "8000 New St " ),
681+ $ result = $ this -> graphQlMutation (
682+ $ this -> getUpdateAddressStreetMutation ($ addressId , "8000 New St " ),
731683 [],
732684 '' ,
733685 ['Authorization ' => 'Bearer ' . $ tokenString ]
734686 );
735- self :: assertEquals ($ addressId , $ result ['updateCustomerAddress ' ]['id ' ]);
736- self :: assertEquals ("8000 New St " , $ result ['updateCustomerAddress ' ]['street ' ][0 ]);
687+ $ this -> assertEquals ($ addressId , $ result ['updateCustomerAddress ' ]['id ' ]);
688+ $ this -> assertEquals ("8000 New St " , $ result ['updateCustomerAddress ' ]['street ' ][0 ]);
737689 },
738690 ],
739691 ];
@@ -743,7 +695,7 @@ function (CustomerInterface $customer, $tokenString) {
743695 * @param string $streetAddress
744696 * @return string
745697 */
746- private static function getCreateAddressMutation ($ streetAddress )
698+ private function getCreateAddressMutation ($ streetAddress )
747699 {
748700 return <<<MUTATIONCREATE
749701mutation{
@@ -781,7 +733,7 @@ private static function getCreateAddressMutation($streetAddress)
781733 * @param string $streetAddress
782734 * @return string
783735 */
784- private static function getUpdateAddressStreetMutation ($ addressId , $ streetAddress )
736+ private function getUpdateAddressStreetMutation ($ addressId , $ streetAddress )
785737 {
786738 return <<<MUTATIONUPDATE
787739mutation{
@@ -828,7 +780,7 @@ private function assertTagsByCacheKeyAndCustomer(string $cacheKey, CustomerInter
828780 );
829781 }
830782
831- private function getProviderInterfaceMock ()
783+ private function getCacheKeyForCustomerResolver (): string
832784 {
833785 $ resolverMock = $ this ->getMockBuilder (CustomerResolver::class)
834786 ->disableOriginalConstructor ()
@@ -841,13 +793,6 @@ private function getProviderInterfaceMock()
841793 ->getKeyCalculatorForResolver ($ resolverMock )
842794 ->calculateCacheKey ();
843795
844- return $ cacheKeyFactor ;
845- }
846-
847- private static function getCacheKeyForCustomerResolver (): array
848- {
849- $ cacheKeyFactor = static fn (self $ testCase ) => $ testCase ->getProviderInterfaceMock ();
850-
851796 $ cacheKeyQueryPayloadMetadata = CustomerResolver::class . '\Interceptor[] ' ;
852797
853798 $ cacheKeyParts = [
@@ -857,10 +802,10 @@ private static function getCacheKeyForCustomerResolver(): array
857802 ];
858803
859804 // strtoupper is called in \Magento\Framework\Cache\Frontend\Adapter\Zend::_unifyId
860- return $ cacheKeyParts ;
805+ return strtoupper ( implode ( ' _ ' , $ cacheKeyParts)) ;
861806 }
862807
863- private static function getCustomerQuery (): string
808+ private function getCustomerQuery (): string
864809 {
865810 return <<<QUERY
866811 {
0 commit comments