PHP Errors: the Test
class LoginTest extends TestCase {
public function test_redirect() {
// Establish the error handler with the expected message.
$expected_error = 'Notice: Undefined variable: nada';
$this->expected_errors($expected_error);
// Call the function to be tested.
$actual = some_procedure();
// Make sure the error happened.
$this->assertTrue($this->were_expected_errors_found(),
"Expected error not found: '$expected_error'");
// Check that the result matches.
$this->assertEquals('Hello!', $actual);
}
}