Timeline for PHPUnit assert that an exception was thrown?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 10, 2023 at 19:54 | history | edited | danronmoon | CC BY-SA 4.0 |
Grammar
|
May 9, 2022 at 15:53 | comment | added | Sébastien |
@LucasBustamante expectExceptionMessage($message) will work as long as the actual exception message contains the specified message. Internally PHPUnit uses strpos to evaluate the condition.
|
|
Oct 15, 2020 at 3:02 | comment | added | darryn.ten |
this is the one! also, expectExceptionCode(401)
|
|
Jun 25, 2020 at 17:08 | comment | added | Lucas Bustamante |
It seems that expectExceptionMessage behaves as a Regex. If your error message is 'Foo bar Baz', $this->expectExceptionMessage('Foo'); will make the test pass.
|
|
Dec 4, 2019 at 4:03 | comment | added | AndrewMcLagan | For sure the most sugar in this syntax | |
S Sep 20, 2018 at 8:35 | history | edited | Amit Ray | CC BY-SA 4.0 |
Corrected Spelling
|
S Sep 20, 2018 at 8:35 | history | suggested | Danon | CC BY-SA 4.0 |
Add markup
|
Sep 20, 2018 at 8:30 | review | Suggested edits | |||
S Sep 20, 2018 at 8:35 | |||||
Mar 29, 2017 at 6:23 | review | Late answers | |||
Mar 29, 2017 at 6:31 | |||||
Mar 29, 2017 at 6:03 | history | answered | Antonis Charalambous | CC BY-SA 3.0 |