In my unit test I want to caught if an ArithmeticError has been thrown, just like for an Exception using the @expectedException tag.
Unfortunally, it seems that phpunit recognize only Exceptions and not Errors.
Anyone know how to test for expected errors, instead excpetions?
Found the solution. Using
error_reporting(2);in a TestCase's setUp method ensure phpunit can convert all Errors in Exceptions. I tried various error reporting levels, but only the one above works (see the error reporting levels). In this case was simple to me:Now this test returns Success!!! For more information visit Testing PHP Errors.