Skip to content

Commit

Permalink
improved error message for assertion assertCount
Browse files Browse the repository at this point in the history
  • Loading branch information
konecnyjakub committed Dec 20, 2024
1 parent 44ce2cd commit 9cf6fbe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Version 7.0.0+dev
- filename of generated code coverage report is now shown in console (if a report is generated and is saved into a file)
- callbacks in Job::$onAfterExecute receive Job as first parameter
- improved error message for assertion assertCount

Version 7.0.0
- BC break: used interfaces for data provider and skip checker in TestCase
Expand Down
2 changes: 1 addition & 1 deletion src/TAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected function assertCount(int $count, array|\Countable $value): void
{
$actual = count($value);
$success = ($actual === $count);
$message = ($success) ? "" : "Count of the variable is $actual.";
$message = ($success) ? "" : "Count of the variable is not $count but $actual.";
$this->testResult($message, $success);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function testAssertionFailures(): void
"Test 37 failed. array (\n 0 => 'abc',\n 1 => 'def',\n) is not in the variable.");
$this->assertThrowsException(function () {
$this->assertCount(1, ["abc", "def", ]);
}, AssertionFailedException::class, "Test 39 failed. Count of the variable is 2.");
}, AssertionFailedException::class, "Test 39 failed. Count of the variable is not 1 but 2.");
$this->assertThrowsException(function () {
$this->assertNotCount(2, ["abc", "def", ]);
}, AssertionFailedException::class, "Test 41 failed. Count of the variable is 2.");
Expand Down

0 comments on commit 9cf6fbe

Please sign in to comment.