diff --git a/src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php b/src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php index 7aea39a..f4fc89c 100644 --- a/src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php +++ b/src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php @@ -10,6 +10,7 @@ use PHPStan\Type\GeneralizePrecision; use PHPStan\Type\TypeCombinator; use function count; +use function in_array; use function strtolower; /** @@ -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 []; } diff --git a/tests/Rules/PHPUnit/AssertEqualsIsDiscouragedRuleTest.php b/tests/Rules/PHPUnit/AssertEqualsIsDiscouragedRuleTest.php index e739ee4..f1d34d0 100644 --- a/tests/Rules/PHPUnit/AssertEqualsIsDiscouragedRuleTest.php +++ b/tests/Rules/PHPUnit/AssertEqualsIsDiscouragedRuleTest.php @@ -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], ]); } diff --git a/tests/Rules/PHPUnit/data/assert-equals-is-discouraged.php b/tests/Rules/PHPUnit/data/assert-equals-is-discouraged.php index 727408d..7f4d80e 100644 --- a/tests/Rules/PHPUnit/data/assert-equals-is-discouraged.php +++ b/tests/Rules/PHPUnit/data/assert-equals-is-discouraged.php @@ -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); } }