Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e32ac65

Browse files
staabmondrejmirtes
authored andcommitted
Support assertNotEquals in AssertEqualsIsDiscouragedRule
1 parent 2cedfb7 commit e32ac65

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

‎src/Rules/PHPUnit/AssertEqualsIsDiscouragedRule.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use PHPStan\Type\GeneralizePrecision;
1111
use PHPStan\Type\TypeCombinator;
1212
use function count;
13+
use function in_array;
1314
use function strtolower;
1415

1516
/**
@@ -32,7 +33,10 @@ public function processNode(Node $node, Scope $scope): array
3233
if (count($node->getArgs()) < 2) {
3334
return [];
3435
}
35-
if (!$node->name instanceof Node\Identifier || strtolower($node->name->name) !== 'assertequals') {
36+
if (
37+
!$node->name instanceof Node\Identifier
38+
|| !in_array(strtolower($node->name->name), ['assertequals', 'assertnotequals'], true)
39+
) {
3640
return [];
3741
}
3842

‎tests/Rules/PHPUnit/AssertEqualsIsDiscouragedRuleTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public function testRule(): void
2727
[self::ERROR_MESSAGE, 29],
2828
[self::ERROR_MESSAGE, 30],
2929
[self::ERROR_MESSAGE, 32],
30+
[self::ERROR_MESSAGE, 37],
31+
[self::ERROR_MESSAGE, 38],
32+
[self::ERROR_MESSAGE, 39],
3033
]);
3134
}
3235

‎tests/Rules/PHPUnit/data/assert-equals-is-discouraged.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@ public function dummyTest(string $string, int $integer, bool $boolean, float $fl
3333
$this->assertEquals([], []);
3434
$this->assertEquals(new Exception(), new Exception());
3535
static::assertEquals(new Exception(), new Exception());
36+
37+
$this->assertNotEquals($string, $string);
38+
$this->assertNotEquals($integer, $integer);
39+
$this->assertNotEquals($boolean, $boolean);
40+
$this->assertNotSame(5, $integer);
41+
static::assertNotSame(5, $integer);
3642
}
3743
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /