Test for calling ErrorAction->setAjaxError() for ajax-based actions

This commit is contained in:
Anton Terekhov
2012-11-21 14:47:35 +04:00
parent a789ad8966
commit 3517a6450c

View File

@ -47,7 +47,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
$this->getMock('ErrorLayout', array('fetch', 'setException'), array(), 'ErrorLayoutMock'); $this->getMock('ErrorLayout', array('fetch', 'setException'), array(), 'ErrorLayoutMock');
} }
if (!class_exists('ErrorActionMock')) { if (!class_exists('ErrorActionMock')) {
$this->getMock('ErrorAction', array(), array(), 'ErrorActionMock', false); $this->getMock('ErrorAction', array('setAjaxError'), array(), 'ErrorActionMock', false);
} }
set_new_overload(array($this, 'newCallback')); set_new_overload(array($this, 'newCallback'));
} }
@ -231,6 +231,21 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
/** /**
* @runInSeparateProcess * @runInSeparateProcess
*/ */
public function testExecuteWithAjaxActionError()
{
$this->getMock('userAction');
$_SERVER['REQUEST_URI'] = '/user/account/213';
$this->setConstants(false);
$controller = FrontController::getInstance();
$router = $controller->getRouter();
$router->add('user', 'user/account/:id', 'NewAjax');
$result = $controller->execute();
$this->assertNull($result);
}
/**
* @runInSeparateProcess
*/
public function testExecuteWithAjaxActionProfiler() public function testExecuteWithAjaxActionProfiler()
{ {
Config::set('PROFILER', true); Config::set('PROFILER', true);
@ -276,6 +291,9 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase
/** /**
* Used in testExecuteWithAjaxAction * Used in testExecuteWithAjaxAction
*/ */
class NewAjaxAction extends AjaxAction{ class NewAjaxAction extends AjaxAction
protected function execute() {} {
protected function execute()
{
}
} }