Skip to content

Commit

Permalink
Closes #2731
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 14, 2017
1 parent 6727744 commit 2decef4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog-6.4.md
Expand Up @@ -5,6 +5,7 @@ All notable changes of the PHPUnit 6.4 release series are documented in this fil
## [6.4.2] - 2017-10-13

* Fixed [#2688](https://github.com/sebastianbergmann/phpunit/issues/2688): `assertNotContains()` interferes with actual string
* Fixed [#2731](https://github.com/sebastianbergmann/phpunit/issues/2731): Empty exception message cannot be expected
* Fixed [#2778](https://github.com/sebastianbergmann/phpunit/issues/2778): `assertContains()` does not handle empty strings in strings correctly

## [6.4.1] - 2017-10-07
Expand Down
15 changes: 15 additions & 0 deletions src/Framework/Constraint/ExceptionMessage.php
Expand Up @@ -36,6 +36,10 @@ public function __construct($expected)
*/
protected function matches($other)
{
if ($this->expectedMessage === '') {
return $other->getMessage() === '';
}

return \strpos($other->getMessage(), $this->expectedMessage) !== false;
}

Expand All @@ -51,6 +55,13 @@ protected function matches($other)
*/
protected function failureDescription($other)
{
if ($this->expectedMessage === '') {
return \sprintf(
"exception message is empty but is '%s'",
$other->getMessage()
);
}

return \sprintf(
"exception message '%s' contains '%s'",
$other->getMessage(),
Expand All @@ -63,6 +74,10 @@ protected function failureDescription($other)
*/
public function toString()
{
if ($this->expectedMessage === '') {
return 'exception message is empty';
}

return 'exception message contains ';
}
}

0 comments on commit 2decef4

Please sign in to comment.