Timeline for How to unit test Exceptions with PHPUnit?
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 20, 2018 at 15:41 | comment | added | Invincible | Works like a charm | |
Sep 14, 2017 at 13:18 | comment | added | Eugene Kaurov | in PHPunit 6+ we need to use public function testGetPhone() { $this->expectException(\InvalidArgumentException::class); some code cause exception here } | |
May 6, 2017 at 16:43 | comment | added | dotnetCarpenter | At least from phpunit 6.1 this doesn't work anymore. You should be as specific as possible when testing exceptions. Testing for classes that are too generic might lead to undesirable side-effects. Accordingly, testing for the Exception class with @expectedException or setExpectedException() is no longer permitted. phpunit.de/manual/current/en/… | |
Aug 4, 2015 at 3:53 | history | answered | Aldee | CC BY-SA 3.0 |