Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/sets/phpunit-code-quality.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -46,7 +46,7 @@
ConstructClassMethodToSetUpTestCaseRector::class,

AssertSameTrueFalseToAssertTrueFalseRector::class,
MatchAssertSameExpectedTypeRector::class,
MatchAssertEqualsExpectedTypeRector::class,

AssertEqualsToSameRector::class,
PreferPHPUnitThisCallRector::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

final class MatchAssertType extends TestCase
{
public function test()
{
$this->assertSame('123', $this->getOrderId());
$this->assertEquals('123', $this->getOrderId());
}

private function getOrderId(): int
Expand All @@ -21,15 +21,15 @@ final class MatchAssertType extends TestCase
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

final class MatchAssertType extends TestCase
{
public function test()
{
$this->assertSame(123, $this->getOrderId());
$this->assertEquals(123, $this->getOrderId());
}

private function getOrderId(): int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

final class MatchIntegerToString extends TestCase
{
public function test()
{
$this->assertSame(123, $this->getOrderId());
$this->assertEquals(123, $this->getOrderId());
}

private function getOrderId(): string
Expand All @@ -21,15 +21,15 @@ final class MatchIntegerToString extends TestCase
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

final class MatchIntegerToString extends TestCase
{
public function test()
{
$this->assertSame('123', $this->getOrderId());
$this->assertEquals('123', $this->getOrderId());
}

private function getOrderId(): string
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

final class NullableMatchAssertType extends TestCase
{
public function test()
{
$this->assertSame('123', $this->getOrderId());
$this->assertEquals('123', $this->getOrderId());
}

private function getOrderId(): ?int
Expand All @@ -21,15 +21,15 @@ final class NullableMatchAssertType extends TestCase
-----
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

final class NullableMatchAssertType extends TestCase
{
public function test()
{
$this->assertSame(123, $this->getOrderId());
$this->assertEquals(123, $this->getOrderId());
}

private function getOrderId(): ?int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector\Fixture;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector\Fixture;

use PHPUnit\Framework\TestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

declare(strict_types=1);

namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertSameExpectedTypeRector;
namespace Rector\PHPUnit\Tests\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector;

use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;

final class MatchAssertSameExpectedTypeRectorTest extends AbstractRectorTestCase
final class MatchAssertEqualsExpectedTypeRectorTest extends AbstractRectorTestCase
{
#[DataProvider('provideData')]
public function test(string $filePath): void
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\CodeQuality\Rector\MethodCall\MatchAssertEqualsExpectedTypeRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rule(MatchAssertEqualsExpectedTypeRector::class);
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
}

Expand Down