PhpStorm 2023.3 Help

Code Inspection: Deprecated 'assertEquals/assertNotEquals' usage

Reports deprecated usages of the assertEquals and assertNotEquals functions with $delta, $maxDepth, $canonicalize, and $ignoreCase parameters.

The optional $delta, $maxDepth, $canonicalize, and $ignoreCase parameters of the assertEquals and assertNotEquals functions are deprecated and will be removed in PHPUnit 9.

See Usage of the assertEquals function (phpunit.readthedocs.io) for details.

In the following example, the assertEquals() calls are used for asserting several different conditions: whether the string and value values are canonically equal, whether the difference between them is greater than a delta value, and whether they are equal regardless their case. After the quick-fix is applied, the more specific assertEqualsCanonicalizing(), assertEqualsWithDelta(), and assertEqualsIgnoringCase() are used instead.

class Test extends \PHPUnit\Framework\TestCase { public function testSample() { $value = 'value'; $this->assertEquals('string', $value, 'message', 0.0, 10, true); $this->assertEquals('string', $value, 'message', 100.0); $this->assertEquals('string', $value, 'message', 0, 10, false, true); } }
class Test extends \PHPUnit\Framework\TestCase { public function testSample() { $value = 'value'; $this->assertEqualsCanonicalizing('string', $value, 'message'); $this->assertEqualsWithDelta('string', $value, 100.0, 'message'); $this->assertEqualsIgnoringCase('string', $value, 'message'); } }

Suppress an inspection in the editor

  1. Place the caret at the highlighted line and press Alt+Enter or click the Intention action icon.

  2. Click the arrow next to the inspection you want to suppress and select the necessary suppress action.

Last modified: 25 March 2024