PHP Errors: Execution Stops
- Testing function that causes a PHP notice
- PHPUnit turns the notice into an exception
- Immediately halts method execution
function some_procedure() {
echo "$nada\n"; // Execution stops here!
return 'Hello!';
}
/**
* @expectedException PHPUnit_Framework_Error
* @expectedExceptionMessage Notice: Undefined variable: nada
*/
public function test_error() {
$actual = some_procedure();
$this->assertEquals('Hello!', $actual); // This assertion is never run!
}