I am writing test cases and here is a question I have.
So say I am testing a simple function someClass::loadValue($value)
The normal test case
PHPUnit_Util_ErrorHandler::handleError()
throws one of several exception types based on the error code:
PHPUnit_Framework_Error_Notice
for E_NOTICE
, E_USER_NOTICE
, and E_STRICT
PHPUnit_Framework_Error_Warning
for E_WARNING
and E_USER_WARNING
PHPUnit_Framework_Error
for all othersYou can catch and expect these as you would any other exception.
/**
* @expectedException PHPUnit_Framework_Error_Warning
*/
function testNegativeNumberTriggersWarning() {
$fixture = new someClass;
$fixture->loadValue(-1);
}