I have code like this:
class ToBeTested
{
function simpleMethod($param)
{
if(0 === $param)
{
trigger_error("Param is 0!", E_USER_WARNING);
return false;
}
return true;
}
}
and test for this code:
class SimpleTest extends PHPUnit_Framework_TestCase
{
function testSimpleMethod()
{
$toBeTestedObject = new ToBeTested();
$this->assertFalse($toBeTestedObject->simpleMethod(0));
}
}
I know how to test, if the error is triggered ($this->setExpectedException()
), but I don't know how to execute the code after trigger_error()
function.
Remember that in PHPUnit E_USER_WARNING
is not converted into PHPUnit_Framework_Error_Warning
(which can be disabled), but it is converted into PHPUnit_Framework_Error
(which can't be disabled).