|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Exception\Handler; |
| 4 | +use Mockery as m; |
| 5 | + |
| 6 | +class HandlerTest extends PHPUnit_Framework_TestCase |
| 7 | +{ |
| 8 | + protected function setUp() |
| 9 | + { |
| 10 | + $this->responsePreparer = m::mock('Illuminate\Support\Contracts\ResponsePreparerInterface'); |
| 11 | + $this->plainDisplayer = m::mock('Illuminate\Exception\ExceptionDisplayerInterface'); |
| 12 | + $this->debugDisplayer = m::mock('Illuminate\Exception\ExceptionDisplayerInterface'); |
| 13 | + $this->handler = new Handler($this->responsePreparer, $this->plainDisplayer, $this->debugDisplayer); |
| 14 | + } |
| 15 | + |
| 16 | + public function testHandleErrorExceptionArguments() |
| 17 | + { |
| 18 | + $error = null; |
| 19 | + try { |
| 20 | + $this->handler->handleError(E_USER_ERROR, 'message', '/path/to/file', 111, array()); |
| 21 | + } catch (ErrorException $error) {} |
| 22 | + |
| 23 | + $this->assertInstanceOf('ErrorException', $error); |
| 24 | + $this->assertSame(E_USER_ERROR, $error->getSeverity(), 'error handler should not modify severity'); |
| 25 | + $this->assertSame('message', $error->getMessage(), 'error handler should not modify message'); |
| 26 | + $this->assertSame('/path/to/file', $error->getFile(), 'error handler should not modify path'); |
| 27 | + $this->assertSame(111, $error->getLine(), 'error handler should not modify line number'); |
| 28 | + $this->assertSame(0, $error->getCode(), 'error handler should use 0 exception code'); |
| 29 | + } |
| 30 | + |
| 31 | + public function testHandleErrorOptionalArguments() |
| 32 | + { |
| 33 | + $error = null; |
| 34 | + try { |
| 35 | + $this->handler->handleError(E_USER_ERROR, 'message'); |
| 36 | + } catch (ErrorException $error) {} |
| 37 | + |
| 38 | + $this->assertInstanceOf('ErrorException', $error); |
| 39 | + $this->assertSame('', $error->getFile(), 'error handler should use correct default path'); |
| 40 | + $this->assertSame(0, $error->getLine(), 'error handler should use correct default line'); |
| 41 | + } |
| 42 | +} |
0 commit comments