Skip to content

Commit a09b194

Browse files
ShradddhaShradddha
authored andcommitted
AC-12092:: Remove Deprecations- PhpUnit10 Unit Tests
1 parent 647a9c3 commit a09b194

File tree

4 files changed

+29
-38
lines changed

4 files changed

+29
-38
lines changed

app/code/Magento/PageCache/Test/Unit/Model/Layout/LayoutPluginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testAfterGenerateElements($cacheState, $layoutIsCacheable, $main
102102
/**
103103
* @return array
104104
*/
105-
public function afterGenerateElementsDataProvider(): array
105+
public static function afterGenerateElementsDataProvider(): array
106106
{
107107
return [
108108
'Full_cache state is true, Layout is cache-able' => [true, true, false],

dev/tests/api-functional/testsuite/Magento/GraphQl/CustomerGraphQl/Model/Resolver/CustomerTest.php

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
use Magento\TestFramework\Helper\Bootstrap;
2828
use Magento\TestFramework\TestCase\GraphQl\ResolverCacheAbstract;
2929
use Magento\TestFramework\TestCase\GraphQl\ResponseContainsErrorsException;
30-
use PHPUnit\Framework\MockObject\MockObject;
31-
use PHPUnit\Framework\TestCase;
3230

3331
/**
3432
* Test for customer resolver cache
@@ -62,11 +60,6 @@ class CustomerTest extends ResolverCacheAbstract
6260
*/
6361
private $registry;
6462

65-
/**
66-
* @var CustomerResolver|MockObject
67-
*/
68-
private static $resolverMock;
69-
7063
protected function setUp(): void
7164
{
7265
$this->objectManager = Bootstrap::getObjectManager();
@@ -88,10 +81,6 @@ protected function setUp(): void
8881
$this->registry->unregister('isSecureArea');
8982
$this->registry->register('isSecureArea', true);
9083

91-
self::$resolverMock = $this->getMockBuilder(CustomerResolver::class)
92-
->disableOriginalConstructor()
93-
->getMock();
94-
9584
parent::setUp();
9685
}
9786

@@ -310,13 +299,13 @@ public function testCustomerResolverCacheInvalidationOnStoreChange()
310299
* @param CustomerInterface $customer
311300
* @return void
312301
*/
313-
private static function assertCurrentCustomerCacheRecordExists(CustomerInterface $customer)
302+
private function assertCurrentCustomerCacheRecordExists(CustomerInterface $customer)
314303
{
315-
$cacheKey = self::getCacheKeyForCustomerResolver();
304+
$cacheKey = $this->getCacheKeyForCustomerResolver();
316305
$cacheEntry = Bootstrap::getObjectManager()->get(GraphQlResolverCache::class)->load($cacheKey);
317306
$cacheEntryDecoded = json_decode($cacheEntry, true);
318307

319-
self::assertEquals(
308+
$this->assertEquals(
320309
$customer->getEmail(),
321310
$cacheEntryDecoded['email']
322311
);
@@ -629,7 +618,7 @@ public function testCustomerQueryingCustomerWithDifferentStoreHeaderDoesNotGener
629618
);
630619
}
631620

632-
public static function invalidationMechanismProvider(): array
621+
public function invalidationMechanismProvider(): array
633622
{
634623
// provider is invoked before setUp() is called so need to init here
635624
$repo = Bootstrap::getObjectManager()->get(
@@ -652,51 +641,51 @@ function (CustomerInterface $customer) use ($repo) {
652641
'add and delete address' => [
653642
function (CustomerInterface $customer, $tokenString) {
654643
// create new address because default billing address cannot be deleted
655-
self::graphQlMutation(
656-
self::getCreateAddressMutation("4000 Polk St"),
644+
$this->graphQlMutation(
645+
$this->getCreateAddressMutation("4000 Polk St"),
657646
[],
658647
'',
659648
['Authorization' => 'Bearer ' . $tokenString]
660649
);
661650
// query for customer to cache data after address creation
662-
$result = self::graphQlQuery(
663-
self::getCustomerQuery(),
651+
$result = $this->graphQlQuery(
652+
$this->getCustomerQuery(),
664653
[],
665654
'',
666655
['Authorization' => 'Bearer ' . $tokenString]
667656
);
668657
// assert that cache record exists for given customer
669-
self::assertCurrentCustomerCacheRecordExists($customer);
658+
$this->assertCurrentCustomerCacheRecordExists($customer);
670659

671660
$addressId = $result['customer']['addresses'][1]['id'];
672-
$result = self::graphQlMutation(
673-
self::getDeleteAddressMutation($addressId),
661+
$result = $this->graphQlMutation(
662+
$this->getDeleteAddressMutation($addressId),
674663
[],
675664
'',
676665
['Authorization' => 'Bearer ' . $tokenString]
677666
);
678-
self::assertTrue($result['deleteCustomerAddress']);
667+
$this->assertTrue($result['deleteCustomerAddress']);
679668
},
680669
],
681670
'update address' => [
682671
function (CustomerInterface $customer, $tokenString) {
683672
// query for customer to cache data after address creation
684-
$result = self::graphQlQuery(
685-
self::getCustomerQuery(),
673+
$result = $this->graphQlQuery(
674+
$this->getCustomerQuery(),
686675
[],
687676
'',
688677
['Authorization' => 'Bearer ' . $tokenString]
689678
);
690679

691680
$addressId = $result['customer']['addresses'][0]['id'];
692-
$result = self::graphQlMutation(
693-
self::getUpdateAddressStreetMutation($addressId, "8000 New St"),
681+
$result = $this->graphQlMutation(
682+
$this->getUpdateAddressStreetMutation($addressId, "8000 New St"),
694683
[],
695684
'',
696685
['Authorization' => 'Bearer ' . $tokenString]
697686
);
698-
self::assertEquals($addressId, $result['updateCustomerAddress']['id']);
699-
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]);
700689
},
701690
],
702691
];
@@ -706,7 +695,7 @@ function (CustomerInterface $customer, $tokenString) {
706695
* @param string $streetAddress
707696
* @return string
708697
*/
709-
private static function getCreateAddressMutation($streetAddress)
698+
private function getCreateAddressMutation($streetAddress)
710699
{
711700
return <<<MUTATIONCREATE
712701
mutation{
@@ -744,7 +733,7 @@ private static function getCreateAddressMutation($streetAddress)
744733
* @param string $streetAddress
745734
* @return string
746735
*/
747-
private static function getUpdateAddressStreetMutation($addressId, $streetAddress)
736+
private function getUpdateAddressStreetMutation($addressId, $streetAddress)
748737
{
749738
return <<<MUTATIONUPDATE
750739
mutation{
@@ -765,7 +754,7 @@ private static function getUpdateAddressStreetMutation($addressId, $streetAddres
765754
* @param int $addressId
766755
* @return string
767756
*/
768-
private static function getDeleteAddressMutation($addressId)
757+
private function getDeleteAddressMutation($addressId)
769758
{
770759
return <<<MUTATIONDELETE
771760
mutation{
@@ -791,9 +780,11 @@ private function assertTagsByCacheKeyAndCustomer(string $cacheKey, CustomerInter
791780
);
792781
}
793782

794-
private static function getCacheKeyForCustomerResolver(): string
783+
private function getCacheKeyForCustomerResolver(): string
795784
{
796-
$resolverMock = self::$resolverMock;
785+
$resolverMock = $this->getMockBuilder(CustomerResolver::class)
786+
->disableOriginalConstructor()
787+
->getMock();
797788

798789
/** @var ProviderInterface $cacheKeyCalculatorProvider */
799790
$cacheKeyCalculatorProvider = Bootstrap::getObjectManager()->get(ProviderInterface::class);
@@ -814,7 +805,7 @@ private static function getCacheKeyForCustomerResolver(): string
814805
return strtoupper(implode('_', $cacheKeyParts));
815806
}
816807

817-
private static function getCustomerQuery(): string
808+
private function getCustomerQuery(): string
818809
{
819810
return <<<QUERY
820811
{

dev/tests/api-functional/testsuite/Magento/TestModuleOverrideConfig/MagentoApiConfigFixture/ReplaceFixtureTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function testReplaceFixtureForMethod(string $expectedConfigValue): void
8585
/**
8686
* @return array
8787
*/
88-
public function testDataProvider(): array
88+
public static function testDataProvider(): array
8989
{
9090
return [
9191
'first_data_set' => [

lib/internal/Magento/Framework/Validator/Test/Unit/Constraint/PropertyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testIsValid(
106106
*
107107
* @return array
108108
*/
109-
public function isValidDataProvider()
109+
public static function isValidDataProvider()
110110
{
111111
return [
112112
[[self::PROPERTY_NAME => 'Property value', 'foo' => 'Foo value'], 'Property value', true],

0 commit comments

Comments
 (0)