Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 70d94d5

Browse files
committed
Merge pull request laravel#3802 from ezzatron/error-exception-arguments
Fixed 2 bugs in the error handler implementation
2 parents 58b1819 + f1968fb commit 70d94d5

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

src/Illuminate/Exception/Handler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ protected function registerShutdownHandler()
126126
*
127127
* @throws \ErrorException
128128
*/
129-
public function handleError($level, $message, $file, $line, $context)
129+
public function handleError($level, $message, $file = '', $line = 0, $context = array())
130130
{
131131
if (error_reporting() & $level)
132132
{
133-
throw new ErrorException($message, $level, 0, $file, $line);
133+
throw new ErrorException($message, 0, $level, $file, $line);
134134
}
135135
}
136136

tests/Exception/HandlerTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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

Comments
 (0)