diff --git a/config/sets/phpunit-code-quality.php b/config/sets/phpunit-code-quality.php index 9ac2ba9f..9d9dec95 100644 --- a/config/sets/phpunit-code-quality.php +++ b/config/sets/phpunit-code-quality.php @@ -31,7 +31,7 @@ use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertSameTrueFalseToAssertTrueFalseRector; use Rector\PHPUnit\CodeQuality\Rector\MethodCall\AssertTrueFalseToSpecificMethodRector; use Rector\PHPUnit\CodeQuality\Rector\MethodCall\FlipAssertRector; -use Rector\PHPUnit\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector; +use Rector\PHPUnit\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector; use Rector\PHPUnit\CodeQuality\Rector\MethodCall\NarrowIdenticalWithConsecutiveRector; use Rector\PHPUnit\CodeQuality\Rector\MethodCall\NarrowSingleWillReturnCallbackRector; use Rector\PHPUnit\CodeQuality\Rector\MethodCall\RemoveExpectAnyFromMockRector; @@ -46,7 +46,7 @@ ConstructClassMethodToSetUpTestCaseRector::class, AssertSameTrueFalseToAssertTrueFalseRector::class, - MatchAssertSameExpectedTypeRector::class, + MatchAssertEqualsExpectedTypeRector::class, AssertEqualsToSameRector::class, PreferPHPUnitThisCallRector::class, diff --git a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/match_assert_type.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/match_assert_type.php.inc similarity index 73% rename from rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/match_assert_type.php.inc rename to rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/match_assert_type.php.inc index 1c537c53..0ad61056 100644 --- a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/match_assert_type.php.inc +++ b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/match_assert_type.php.inc @@ -1,6 +1,6 @@ assertSame('123', $this->getOrderId()); + $this->assertEquals('123', $this->getOrderId()); } private function getOrderId(): int @@ -21,7 +21,7 @@ final class MatchAssertType extends TestCase ----- assertSame(123, $this->getOrderId()); + $this->assertEquals(123, $this->getOrderId()); } private function getOrderId(): int diff --git a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/match_integer_to_string.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/match_integer_to_string.php.inc similarity index 74% rename from rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/match_integer_to_string.php.inc rename to rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/match_integer_to_string.php.inc index 4f0d419e..7ffa0666 100644 --- a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/match_integer_to_string.php.inc +++ b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/match_integer_to_string.php.inc @@ -1,6 +1,6 @@ assertSame(123, $this->getOrderId()); + $this->assertEquals(123, $this->getOrderId()); } private function getOrderId(): string @@ -21,7 +21,7 @@ final class MatchIntegerToString extends TestCase ----- assertSame('123', $this->getOrderId()); + $this->assertEquals('123', $this->getOrderId()); } private function getOrderId(): string diff --git a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/nullable_match_assert_type.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/nullable_match_assert_type.php.inc similarity index 74% rename from rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/nullable_match_assert_type.php.inc rename to rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/nullable_match_assert_type.php.inc index db905973..3a4718d1 100644 --- a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/nullable_match_assert_type.php.inc +++ b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/nullable_match_assert_type.php.inc @@ -1,6 +1,6 @@ assertSame('123', $this->getOrderId()); + $this->assertEquals('123', $this->getOrderId()); } private function getOrderId(): ?int @@ -21,7 +21,7 @@ final class NullableMatchAssertType extends TestCase ----- assertSame(123, $this->getOrderId()); + $this->assertEquals(123, $this->getOrderId()); } private function getOrderId(): ?int diff --git a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_argument_less.php.inc b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/skip_argument_less.php.inc similarity index 84% rename from rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_argument_less.php.inc rename to rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/skip_argument_less.php.inc index 1bbaceb1..a468892d 100644 --- a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/Fixture/skip_argument_less.php.inc +++ b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector/Fixture/skip_argument_less.php.inc @@ -1,6 +1,6 @@ rule(MatchAssertEqualsExpectedTypeRector::class); +}; diff --git a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/config/configured_rule.php b/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/config/configured_rule.php deleted file mode 100644 index bc288d66..00000000 --- a/rules-tests/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector/config/configured_rule.php +++ /dev/null @@ -1,10 +0,0 @@ -rule(MatchAssertSameExpectedTypeRector::class); -}; diff --git a/rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php b/rules/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector.php similarity index 88% rename from rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php rename to rules/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector.php index 575ce818..2807ee3f 100644 --- a/rules/CodeQuality/Rector/MethodCall/MatchAssertSameExpectedTypeRector.php +++ b/rules/CodeQuality/Rector/MethodCall/MatchAssertEqualsExpectedTypeRector.php @@ -16,9 +16,9 @@ use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** - * @see \Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\MatchAssertSameExpectedTypeRectorTest + * @see \Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\MatchAssertEqualsExpectedTypeRectorTest */ -final class MatchAssertSameExpectedTypeRector extends AbstractRector +final class MatchAssertEqualsExpectedTypeRector extends AbstractRector { public function __construct( private readonly TestsNodeAnalyzer $testsNodeAnalyzer @@ -28,7 +28,7 @@ public function __construct( public function getRuleDefinition(): RuleDefinition { return new RuleDefinition( - 'Correct expected type in assertSame() method to match strict type of passed variable', + 'Correct expected type in assertEquals() method to match strict type of passed variable', [ new CodeSample( <<<'CODE_SAMPLE' @@ -38,7 +38,7 @@ class SomeTest extends TestCase { public function run() { - $this->assertSame('123', $this->getOrderId()); + $this->assertEquals('123', $this->getOrderId()); } private function getOrderId(): int @@ -55,7 +55,7 @@ class SomeTest extends TestCase { public function run() { - $this->assertSame(123, $this->getOrderId()); + $this->assertEquals(123, $this->getOrderId()); } private function getOrderId(): int @@ -82,7 +82,7 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { - if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertSame', 'assertEquals'])) { + if (! $this->testsNodeAnalyzer->isPHPUnitMethodCallNames($node, ['assertEquals'])) { return null; }