Skip to content

Commit 0b965e9

Browse files
authored
Rector: updated UnitTests (#4391)
* rector unit tests * rector phpunit * rector privatization * Revert "rector privatization" This reverts commit 0ac365a.
1 parent 4b6ad39 commit 0b965e9

File tree

21 files changed

+116
-111
lines changed

21 files changed

+116
-111
lines changed

.rector.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,23 @@
3939
DeadCode\ClassMethod\RemoveUselessReturnTagRector::class,
4040
DeadCode\Property\RemoveUselessVarTagRector::class,
4141
TypeDeclaration\ClassMethod\ReturnNeverTypeRector::class,
42-
]);
42+
])
43+
->withPreparedSets(
44+
false,
45+
false,
46+
false,
47+
false,
48+
false,
49+
false,
50+
false,
51+
false,
52+
false,
53+
false,
54+
false,
55+
true,
56+
false,
57+
false,
58+
false,
59+
false,
60+
true,
61+
);

tests/unit/Base/XmlFileLoadingTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
namespace OpenMage\Tests\Unit\Base;
1919

20+
use Generator;
2021
use PHPUnit\Framework\TestCase;
2122
use SimpleXMLElement;
2223
use XMLReader;
@@ -50,17 +51,12 @@ public function testXmlReaderIsValid(string $filepath): void
5051
$this->assertTrue($xml->isValid());
5152
}
5253

53-
/**
54-
* @return string[][]
55-
*/
56-
public function provideXmlFiles(): array
54+
public function provideXmlFiles(): Generator
5755
{
5856
$root = realpath(__DIR__ . '/../../../') . '/';
5957

60-
return [
61-
'file from vendor directory' => [
62-
$root . 'vendor/shardj/zf1-future/library/Zend/Locale/Data/es_419.xml'
63-
],
58+
yield 'file from vendor directory' => [
59+
$root . 'vendor/shardj/zf1-future/library/Zend/Locale/Data/es_419.xml'
6460
];
6561
}
6662
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ public function testValidate(array $expectedResult, array $methods): void
4848
])
4949
->getMock();
5050

51-
$mock->expects($this->any())->method('getBlockName')->willReturn($methods['getBlockName']);
52-
$mock->expects($this->any())->method('getIsAllowed')->willReturn($methods['getIsAllowed']);
51+
$mock->method('getBlockName')->willReturn($methods['getBlockName']);
52+
$mock->method('getIsAllowed')->willReturn($methods['getIsAllowed']);
5353
$this->assertEquals($expectedResult, $mock->validate());
5454
}
5555

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ public function testAuthenticate($expectedResult, array $methods): void
5656
])
5757
->getMock();
5858

59-
$mock->expects($this->any())->method('loadByUsername')->willReturnSelf();
60-
$mock->expects($this->any())->method('getId')->willReturn($methods['getId']);
59+
$mock->method('loadByUsername')->willReturnSelf();
60+
$mock->method('getId')->willReturn($methods['getId']);
6161
// $mock->expects($this->any())->method('getUsername')->willReturn($methods['getUsername']);
62-
$mock->expects($this->any())->method('getPassword')->willReturn($methods['getPassword']);
63-
$mock->expects($this->any())->method('validatePasswordHash')->willReturn($methods['validatePasswordHash']);
64-
$mock->expects($this->any())->method('getIsActive')->willReturn($methods['getIsActive']);
65-
$mock->expects($this->any())->method('hasAssigned2Role')->willReturn($methods['hasAssigned2Role']);
62+
$mock->method('getPassword')->willReturn($methods['getPassword']);
63+
$mock->method('validatePasswordHash')->willReturn($methods['validatePasswordHash']);
64+
$mock->method('getIsActive')->willReturn($methods['getIsActive']);
65+
$mock->method('hasAssigned2Role')->willReturn($methods['hasAssigned2Role']);
6666

6767
try {
6868
$this->assertSame($expectedResult, $mock->authenticate($methods['getUsername'], $methods['getPassword']));
@@ -136,10 +136,10 @@ public function testValidate($expectedResult, array $methods): void
136136
])
137137
->getMock();
138138

139-
$mock->expects($this->any())->method('hasNewPassword')->willReturn($methods['hasNewPassword']);
140-
$mock->expects($this->any())->method('getNewPassword')->willReturn($methods['getNewPassword']);
141-
$mock->expects($this->any())->method('hasPassword')->willReturn($methods['hasPassword']);
142-
$mock->expects($this->any())->method('getPassword')->willReturn($methods['getPassword']);
139+
$mock->method('hasNewPassword')->willReturn($methods['hasNewPassword']);
140+
$mock->method('getNewPassword')->willReturn($methods['getNewPassword']);
141+
$mock->method('hasPassword')->willReturn($methods['hasPassword']);
142+
$mock->method('getPassword')->willReturn($methods['getPassword']);
143143
$this->assertSame($expectedResult, $mock->validate());
144144
}
145145

@@ -231,8 +231,8 @@ public function testIsResetPasswordLinkTokenExpired(bool $expectedResult, array
231231
])
232232
->getMock();
233233

234-
$mock->expects($this->any())->method('getRpToken')->willReturn($methods['getRpToken']);
235-
$mock->expects($this->any())->method('getRpTokenCreatedAt')->willReturn($methods['getRpTokenCreatedAt']);
234+
$mock->method('getRpToken')->willReturn($methods['getRpToken']);
235+
$mock->method('getRpTokenCreatedAt')->willReturn($methods['getRpTokenCreatedAt']);
236236
$this->assertSame($expectedResult, $mock->isResetPasswordLinkTokenExpired());
237237
}
238238

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function testValidate($expectedResult, string $variableName, string $isAl
4545
->setMethods(['getVariableName', 'getIsAllowed'])
4646
->getMock();
4747

48-
$mock->expects($this->any())->method('getVariableName')->willReturn($variableName);
49-
$mock->expects($this->any())->method('getIsAllowed')->willReturn($isAllowed);
48+
$mock->method('getVariableName')->willReturn($variableName);
49+
$mock->method('getIsAllowed')->willReturn($isAllowed);
5050
$this->assertSame($expectedResult, $mock->validate());
5151
}
5252

tests/unit/Mage/Adminhtml/Block/Customer/Edit/Tab/AddressesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ public function testInitForm(): void
4343
->setMethods(['getRegistryCurrentCustomer', 'isReadonly'])
4444
->getMock();
4545

46-
$mock->expects($this->any())
46+
$mock
4747
->method('getRegistryCurrentCustomer')
4848
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
4949
->willReturn(new Mage_Customer_Model_Customer());
5050

51-
$mock->expects($this->any())
51+
$mock
5252
->method('isReadonly')
5353
->willReturn(true);
5454

tests/unit/Mage/Adminhtml/Block/Customer/Edit/Tab/NewsletterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function testInitForm(): void
4444
->setMethods(['getRegistryCurrentCustomer'])
4545
->getMock();
4646

47-
$mock->expects($this->any())
47+
$mock
4848
->method('getRegistryCurrentCustomer')
4949
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
5050
->willReturn(new Mage_Customer_Model_Customer());

tests/unit/Mage/Adminhtml/Block/System/Convert/Gui/Edit/Tab/ViewTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testInitForm(): void
4343
->setMethods(['getRegistryCurrentConvertProfile'])
4444
->getMock();
4545

46-
$mock->expects($this->any())
46+
$mock
4747
->method('getRegistryCurrentConvertProfile')
4848
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
4949
->willReturn(new Mage_Dataflow_Model_Profile());

tests/unit/Mage/Adminhtml/Block/System/Convert/Profile/Edit/Tab/EditTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testInitForm(): void
4343
->setMethods(['getRegistryCurrentConvertProfile'])
4444
->getMock();
4545

46-
$mock->expects($this->any())
46+
$mock
4747
->method('getRegistryCurrentConvertProfile')
4848
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
4949
->willReturn(new Mage_Dataflow_Model_Profile());

tests/unit/Mage/Catalog/Helper/Product/UrlTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function setUp(): void
3939
public function testGetConvertTable(): void
4040
{
4141
$this->assertIsArray($this->subject->getConvertTable());
42-
$this->assertSame(317, count($this->subject->getConvertTable()));
42+
$this->assertCount(317, $this->subject->getConvertTable());
4343
}
4444

4545
/**

0 commit comments

Comments
 (0)