From 3517a6450cea7b463c93e718ae30a834e853cd87 Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Wed, 21 Nov 2012 14:47:35 +0400 Subject: [PATCH] Test for calling ErrorAction->setAjaxError() for ajax-based actions --- tests/app/FrontControllerTest.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/app/FrontControllerTest.php b/tests/app/FrontControllerTest.php index 8496bd8..1d13571 100644 --- a/tests/app/FrontControllerTest.php +++ b/tests/app/FrontControllerTest.php @@ -47,7 +47,7 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase $this->getMock('ErrorLayout', array('fetch', 'setException'), array(), 'ErrorLayoutMock'); } 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')); } @@ -231,6 +231,21 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase /** * @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() { Config::set('PROFILER', true); @@ -276,6 +291,9 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase /** * Used in testExecuteWithAjaxAction */ -class NewAjaxAction extends AjaxAction{ - protected function execute() {} +class NewAjaxAction extends AjaxAction +{ + protected function execute() + { + } } \ No newline at end of file