Skip to content

Commit f31e568

Browse files
Copilotaddison74sreichelkiatng
authored
Standardize PHPUnit assertion style: replace static::assert* with self::assert* (#4939)
* Initial plan * Standardize PHPUnit assertion style: replace static::assert* with self::assert* Co-authored-by: addison74 <[email protected]> * Change PHPUnit static method call type to 'self' * phpcs-fixer --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: addison74 <[email protected]> Co-authored-by: Sven Reichel <[email protected]> Co-authored-by: Ng Kiat Siong <[email protected]>
1 parent 806f73d commit f31e568

File tree

117 files changed

+592
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+592
-592
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// PHP84: Adds or removes ? before single type declarations or |null at the end of union types when parameters have a default null value.
1616
'nullable_type_declaration_for_default_null_value' => true,
1717
// Calls to PHPUnit\Framework\TestCase static methods must all be of the same type, either $this->, self:: or static::
18-
'php_unit_test_case_static_method_calls' => ['call_type' => 'static'],
18+
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
1919
// Convert double quotes to single quotes for simple strings.
2020
'single_quote' => true,
2121
// Arguments lists, array destructuring lists, arrays that are multi-line, match-lines and parameters lists must have a trailing comma.

tests/unit/Base/ClassLoadingTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class ClassLoadingTest extends TestCase
2121
*/
2222
public function testClassExists(bool $expectedResult, string $class): void
2323
{
24-
static::assertSame($expectedResult, class_exists($class));
24+
self::assertSame($expectedResult, class_exists($class));
2525
}
2626

2727
public function provideClassExistsData(): Generator

tests/unit/Base/DefaultConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class DefaultConfigTest extends TestCase
2424
*/
2525
public function testGetStoreConfig(string $expectedResult, string $path, bool|int|Mage_Core_Model_Store|null|string $store = null): void
2626
{
27-
static::assertSame($expectedResult, Mage::getStoreConfig($path, $store));
27+
self::assertSame($expectedResult, Mage::getStoreConfig($path, $store));
2828
}
2929

3030

tests/unit/Base/XmlFileLoadingTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testFileLoading(string $filepath): void
2929
SimpleXMLElement::class,
3030
LIBXML_PEDANTIC, //not needed by OpenMage, but good to test more strictly
3131
);
32-
static::assertNotEmpty($simplexml->asXML());
32+
self::assertNotEmpty($simplexml->asXML());
3333
}
3434

3535
/**
@@ -40,7 +40,7 @@ public function testXmlReaderIsValid(string $filepath): void
4040
/** @var XMLReader $xml */
4141
$xml = XMLReader::open($filepath);
4242
$xml->setParserProperty(XMLReader::VALIDATE, true);
43-
static::assertTrue($xml->isValid());
43+
self::assertTrue($xml->isValid());
4444
}
4545

4646
public function provideXmlFiles(): Generator

tests/unit/Error/ProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testGetHostUrl(string $expectedResult, array $serverVars): void
3939
foreach ($serverVars as $serverVar => $value) {
4040
$_SERVER[$serverVar] = $value;
4141
}
42-
static::assertSame($expectedResult, $this->subject->getHostUrl());
42+
self::assertSame($expectedResult, $this->subject->getHostUrl());
4343
}
4444

4545
public function provideGetHostUrl(): Generator

tests/unit/Mage/Admin/Helper/BlockTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function setUpBeforeClass(): void
3131
*/
3232
public function testIsTypeAllowed(): void
3333
{
34-
static::assertFalse(self::$subject->isTypeAllowed('some-type'));
34+
self::assertFalse(self::$subject->isTypeAllowed('some-type'));
3535
}
3636

3737
/**
@@ -40,6 +40,6 @@ public function testIsTypeAllowed(): void
4040
*/
4141
public function testGetDisallowedBlockNames(): void
4242
{
43-
static::assertSame(['install/end'], self::$subject->getDisallowedBlockNames());
43+
self::assertSame(['install/end'], self::$subject->getDisallowedBlockNames());
4444
}
4545
}

tests/unit/Mage/Admin/Helper/DataTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function setUpBeforeClass(): void
3131
*/
3232
public function testGenerateResetPasswordLinkToken(): void
3333
{
34-
static::assertIsString(self::$subject->generateResetPasswordLinkToken());
34+
self::assertIsString(self::$subject->generateResetPasswordLinkToken());
3535
}
3636

3737
/**
@@ -40,6 +40,6 @@ public function testGenerateResetPasswordLinkToken(): void
4040
*/
4141
public function testGetResetPasswordLinkExpirationPeriod(): void
4242
{
43-
static::assertIsInt(self::$subject->getResetPasswordLinkExpirationPeriod());
43+
self::assertIsInt(self::$subject->getResetPasswordLinkExpirationPeriod());
4444
}
4545
}

tests/unit/Mage/Admin/Helper/VariableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public static function setUpBeforeClass(): void
3131
*/
3232
public function testIsPathAllowed(): void
3333
{
34-
static::assertIsBool(self::$subject->isPathAllowed(''));
34+
self::assertIsBool(self::$subject->isPathAllowed(''));
3535
}
3636
}

tests/unit/Mage/Admin/Model/BlockTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public function testValidate(bool|array $expectedResult, array $methods): void
4040
{
4141
$mock = $this->getMockWithCalledMethods(Subject::class, $methods);
4242

43-
static::assertInstanceOf(Subject::class, $mock);
44-
static::assertEquals($expectedResult, $mock->validate());
43+
self::assertInstanceOf(Subject::class, $mock);
44+
self::assertEquals($expectedResult, $mock->validate());
4545
}
4646

4747
/**
4848
* @group Model
4949
*/
5050
public function testIsTypeAllowed(): void
5151
{
52-
static::assertIsBool(self::$subject->isTypeAllowed('invalid-type'));
52+
self::assertIsBool(self::$subject->isTypeAllowed('invalid-type'));
5353
}
5454
}

tests/unit/Mage/Admin/Model/ConfigTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@ public static function setUpBeforeClass(): void
3232
*/
3333
public function testGetAclAssert(): void
3434
{
35-
static::assertFalse(self::$subject->getAclAssert(''));
35+
self::assertFalse(self::$subject->getAclAssert(''));
3636
}
3737

3838
/**
3939
* @group Model
4040
*/
4141
public function testGetAclPrivilegeSet(): void
4242
{
43-
static::assertFalse(self::$subject->getAclPrivilegeSet());
43+
self::assertFalse(self::$subject->getAclPrivilegeSet());
4444
}
4545

4646
/**
4747
* @group Model
4848
*/
4949
public function testLoadAclResources(): void
5050
{
51-
static::assertInstanceOf(Subject::class, self::$subject->loadAclResources(new Mage_Admin_Model_Acl()));
51+
self::assertInstanceOf(Subject::class, self::$subject->loadAclResources(new Mage_Admin_Model_Acl()));
5252
}
5353

5454
/**
5555
* @group Model
5656
*/
5757
public function testGetAdminhtmlConfig(): void
5858
{
59-
static::assertInstanceOf(Varien_Simplexml_Config::class, self::$subject->getAdminhtmlConfig());
59+
self::assertInstanceOf(Varien_Simplexml_Config::class, self::$subject->getAdminhtmlConfig());
6060
}
6161
}

0 commit comments

Comments
 (0)