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
6 changes: 5 additions & 1 deletion src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPStan\Type\GeneralizePrecision;
use PHPStan\Type\TypeCombinator;
use function count;
use function in_array;
use function strtolower;

/**
Expand All @@ -32,7 +33,10 @@ public function processNode(Node $node, Scope $scope): array
if (count($node->getArgs()) < 2) {
return [];
}
if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertequals') {
if (
!$node->name instanceof Node\Identifier
|| !in_array(strtolower($node->name->name), ['assertequals', 'assertnotequals'], true)
) {
return [];
}

Expand Down
3 changes: 3 additions & 0 deletions tests/Rules/PHPUnit/AssertEqualsIsDiscouragedRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public function testRule(): void
[self::ERROR_MESSAGE, 29],
[self::ERROR_MESSAGE, 30],
[self::ERROR_MESSAGE, 32],
[self::ERROR_MESSAGE, 37],
[self::ERROR_MESSAGE, 38],
[self::ERROR_MESSAGE, 39],
]);
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Rules/PHPUnit/data/assert-equals-is-discouraged.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,11 @@ public function dummyTest(string $string, int $integer, bool $boolean, float $fl
$this->assertEquals([], []);
$this->assertEquals(new Exception(), new Exception());
static::assertEquals(new Exception(), new Exception());

$this->assertNotEquals($string, $string);
$this->assertNotEquals($integer, $integer);
$this->assertNotEquals($boolean, $boolean);
$this->assertNotSame(5, $integer);
static::assertNotSame(5, $integer);
}
}
Loading