Skip to content

Commit

Permalink
Favour assertSame() over assertEquals()
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Aug 3, 2023
1 parent 9f7422c commit 6fd2727
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,7 @@ private function performAssertionsOnOutput(): void
} elseif ($this->outputExpectedString !== null) {
assert(!empty($this->outputExpectedString));

$this->assertEquals($this->outputExpectedString, $this->output);
$this->assertSame($this->outputExpectedString, $this->output);
}
} catch (ExpectationFailedException $e) {
$this->status = TestStatus::failure($e->getMessage());
Expand Down
8 changes: 4 additions & 4 deletions tests/end-to-end/event/expectation-on-output.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ Test Runner Execution Started (3 tests)
Test Suite Started (PHPUnit\TestFixture\Issue445Test, 3 tests)
Test Preparation Started (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationBefore)
Test Prepared (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationBefore)
Assertion Succeeded (Constraint: is equal to 'test', Value: 'test')
Assertion Succeeded (Constraint: is identical to 'test', Value: 'test')
Test Passed (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationBefore)
Test Finished (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationBefore)
Test Preparation Started (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationAfter)
Test Prepared (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationAfter)
Assertion Succeeded (Constraint: is equal to 'test', Value: 'test')
Assertion Succeeded (Constraint: is identical to 'test', Value: 'test')
Test Passed (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationAfter)
Test Finished (PHPUnit\TestFixture\Issue445Test::testOutputWithExpectationAfter)
Test Preparation Started (PHPUnit\TestFixture\Issue445Test::testNotMatchingOutput)
Test Prepared (PHPUnit\TestFixture\Issue445Test::testNotMatchingOutput)
Assertion Failed (Constraint: is equal to 'foo', Value: 'bar')
Assertion Failed (Constraint: is identical to 'foo', Value: 'bar')
Test Failed (PHPUnit\TestFixture\Issue445Test::testNotMatchingOutput)
Failed asserting that two strings are equal.
Failed asserting that two strings are identical.
Test Finished (PHPUnit\TestFixture\Issue445Test::testNotMatchingOutput)
Test Suite Finished (PHPUnit\TestFixture\Issue445Test, 3 tests)
Test Runner Execution Finished
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/regression/433.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Time: %s, Memory: %s
There was 1 failure:

1) PHPUnit\TestFixture\Issue433Test::testNotMatchingOutput
Failed asserting that two strings are equal.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
Expand Down
2 changes: 1 addition & 1 deletion tests/end-to-end/regression/445.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Time: %s, Memory: %s
There was 1 failure:

1) PHPUnit\TestFixture\Issue445Test::testNotMatchingOutput
Failed asserting that two strings are equal.
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
Expand Down

0 comments on commit 6fd2727

Please sign in to comment.