Skip to content

Commit dde131f

Browse files
authored
Merge pull request #2 from diego-vieira/master
Allow message to be case insensitive
2 parents fcfedb8 + 43bc40a commit dde131f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

AssertThrows.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ public function assertThrowsWithMessage($throws, $message, callable $fn)
3333
$result = $this->getTestResultObject();
3434

3535
if (is_array($throws)) {
36-
$message = ($throws[1]) ? strtolower($throws[1]) : false;
36+
$message = ($throws[1]) ? $throws[1] : false;
3737
$throws = $throws[0];
3838
}
3939

40+
$message = strtolower($message);
41+
4042
try {
4143
call_user_func($fn);
4244
} catch (AssertionFailedError $e) {

tests/AssertThrowsTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public function testExceptionMessageFails()
3535
$this->fail("Ups :(");
3636
}
3737

38+
public function testExceptionMessageCaseInsensitive()
39+
{
40+
$this->assertThrowsWithMessage(MyException::class, "Message and Expected Message CAN have different case", function() {
41+
throw new MyException("Message and expected message can have different case");
42+
});
43+
}
44+
3845
}
3946

4047
class MyException extends Exception {

0 commit comments

Comments
 (0)