Permalink
Browse files

Error Handler: adding better testing and assertions for error trapping

  • Loading branch information...
1 parent 3e71780 commit be56b977e87401238548ddb0826ffb461c45b964 @daschl daschl committed with nateabele Sep 23, 2011
Showing with 11 additions and 1 deletion.
  1. +11 −1 tests/cases/core/ErrorHandlerTest.php
@@ -123,6 +123,9 @@ public function testRun() {
$this->assertEqual(ErrorHandler::isRunning(), false);
ErrorHandler::run();
$this->assertEqual(ErrorHandler::isRunning(), true);
+ $result = ErrorHandler::run();
+ $this->assertEqual(ErrorHandler::isRunning(), true);
+ $this->assertNull($result);
ErrorHandler::stop();
$this->assertEqual(ErrorHandler::isRunning(), false);
}
@@ -147,10 +150,17 @@ public function testReset() {
public function testErrorTrapping() {
ErrorHandler::stop();
+ $self = $this;
+ ErrorHandler::config(array(array(
+ 'handler' => function($info) use ($self) {
+ $self->errors[] = $info;
+ })
+ ));
ErrorHandler::run(array('trapErrors' => true));
- // Undefined offset error shouldn't surface.
+ $this->assertEqual(0, count($this->errors));
list($foo, $bar) = array('baz');
+ $this->assertEqual(1, count($this->errors));
}
public function testRenderedOutput() {

0 comments on commit be56b97

Please sign in to comment.