Skip to content

Commit

Permalink
Merge pull request #2 from diego-vieira/master
Browse files Browse the repository at this point in the history
Allow message to be case insensitive
  • Loading branch information
DavertMik committed Feb 9, 2018
2 parents fcfedb8 + 43bc40a commit dde131f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion AssertThrows.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public function assertThrowsWithMessage($throws, $message, callable $fn)
$result = $this->getTestResultObject();

if (is_array($throws)) {
$message = ($throws[1]) ? strtolower($throws[1]) : false;
$message = ($throws[1]) ? $throws[1] : false;
$throws = $throws[0];
}

$message = strtolower($message);

try {
call_user_func($fn);
} catch (AssertionFailedError $e) {
Expand Down
7 changes: 7 additions & 0 deletions tests/AssertThrowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public function testExceptionMessageFails()
$this->fail("Ups :(");
}

public function testExceptionMessageCaseInsensitive()
{
$this->assertThrowsWithMessage(MyException::class, "Message and Expected Message CAN have different case", function() {
throw new MyException("Message and expected message can have different case");
});
}

}

class MyException extends Exception {
Expand Down

0 comments on commit dde131f

Please sign in to comment.