|
|
@ -12,6 +12,9 @@ |
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/Action_TestCase.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../app/ErrorAction.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../exception/GeneralException.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../exception/ErrorHTTPException.php'; |
|
|
|
require_once dirname(__FILE__) . '/../../exception/Error404Exception.php'; |
|
|
|
|
|
|
|
class ErrorActionTest extends Action_TestCase |
|
|
|
{ |
|
|
@ -24,10 +27,9 @@ class ErrorActionTest extends Action_TestCase |
|
|
|
|
|
|
|
$this->log = ini_get('error_log'); |
|
|
|
ini_set('error_log', '/dev/null'); |
|
|
|
set_exit_overload(function() |
|
|
|
{ |
|
|
|
return false; |
|
|
|
}); |
|
|
|
set_exit_overload(function () { |
|
|
|
return false; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -96,13 +98,15 @@ class ErrorActionTest extends Action_TestCase |
|
|
|
public function testError404WithAjax() |
|
|
|
{ |
|
|
|
$this->setConstants(false); |
|
|
|
$exception = $this->getMock('Error404Exception', array('getMessage', 'getFile', 'getLine', 'getTrace')); |
|
|
|
$exception->expects($this->once()) |
|
|
|
->method('getTrace') |
|
|
|
->will($this->returnValue(array('one' => array('class' => 'AjaxAction')))); |
|
|
|
$exception = new Error404Exception('Some message'); |
|
|
|
|
|
|
|
$controller = FrontController::getInstance(); |
|
|
|
$controller->setView('SomeView'); |
|
|
|
$action = new ErrorAction($exception); |
|
|
|
$action->setAjaxError(); |
|
|
|
$this->assertSame($exception, $action->exception); |
|
|
|
$result = $action->fetch(); |
|
|
|
$this->assertSame('Some message', $result); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -111,13 +115,30 @@ class ErrorActionTest extends Action_TestCase |
|
|
|
public function testError404NoAjax() |
|
|
|
{ |
|
|
|
$this->setConstants(false); |
|
|
|
$exception = $this->getMock('Error404Exception', array('getMessage', 'getFile', 'getLine', 'getTrace')); |
|
|
|
$exception->expects($this->once()) |
|
|
|
->method('getTrace') |
|
|
|
->will($this->returnValue(array('one' => array('class' => 'Action')))); |
|
|
|
$exception = new Error404Exception('Some message'); |
|
|
|
|
|
|
|
$controller = FrontController::getInstance(); |
|
|
|
$controller->setView('SomeView'); |
|
|
|
$action = new ErrorAction($exception); |
|
|
|
$this->assertSame($exception, $action->exception); |
|
|
|
$result = $action->fetch(); |
|
|
|
$this->assertSame('/actions/404', $result['template']); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @runInSeparateProcess |
|
|
|
*/ |
|
|
|
public function testErrorHTTP() |
|
|
|
{ |
|
|
|
$this->setConstants(false); |
|
|
|
$exception = new ErrorHTTPException('Some message', 410); |
|
|
|
|
|
|
|
$controller = FrontController::getInstance(); |
|
|
|
$controller->setView('SomeView'); |
|
|
|
$action = new ErrorAction($exception); |
|
|
|
$this->assertSame($exception, $action->exception); |
|
|
|
$result = $action->fetch(); |
|
|
|
$this->assertSame('/actions/HTTP', $result['template']); |
|
|
|
} |
|
|
|
|
|
|
|
private function setConstants($val = false) |
|
|
|