lithium\tests\cases\core\ErrorHandlerTest::testExceptionCatching PHP Method

testExceptionCatching() public method

    public function testExceptionCatching()
    {
        $self = $this;
        ErrorHandler::config(array(array('type' => 'Exception', 'handler' => function ($info) use($self) {
            $self->errors[] = $info;
        })));
        ErrorHandler::handle(new Exception('Test!'));
        $this->assertCount(1, $this->errors);
        $result = end($this->errors);
        $expected = 'Test!';
        $this->assertEqual($expected, $result['message']);
        $backup = error_reporting();
        error_reporting($backup | E_WARNING);
        $this->assertException('/Test/', function () {
            trigger_error('Test warning!', E_USER_WARNING);
        });
        $this->assertCount(1, $this->errors);
        error_reporting($backup);
    }