|
|
@ -28,6 +28,7 @@ require_once dirname(__FILE__) . '/../../app/AjaxAction.php'; |
|
|
|
|
|
|
|
class FrontControllerTest extends PHPUnit_Framework_TestCase |
|
|
|
{ |
|
|
|
protected $log_file_name = 'error_log_file'; |
|
|
|
|
|
|
|
public function run(PHPUnit_Framework_TestResult $result = NULL) |
|
|
|
{ |
|
|
@ -141,11 +142,14 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase |
|
|
|
public function testExecuteNoRouteDebug() |
|
|
|
{ |
|
|
|
$this->setConstants(true); |
|
|
|
ini_set('error_log', $this->log_file_name); |
|
|
|
$controller = FrontController::getInstance(); |
|
|
|
$result = $controller->execute(); |
|
|
|
$this->assertNotEmpty($result); |
|
|
|
$this->assertContains('Route for "" not found', $result); |
|
|
|
$this->assertContains('Error404Exception', $result); |
|
|
|
$error = file_get_contents($this->log_file_name); |
|
|
|
$this->assertContains('PHP Unknown Error: Route for "" not found', $error); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -155,11 +159,14 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase |
|
|
|
{ |
|
|
|
$_SERVER['REQUEST_URI'] = '/user/account/213'; |
|
|
|
$this->setConstants(true); |
|
|
|
ini_set('error_log', $this->log_file_name); |
|
|
|
$controller = FrontController::getInstance(); |
|
|
|
$router = $controller->getRouter(); |
|
|
|
$router->add('user', 'user/account/:id', 'user'); |
|
|
|
$result = $controller->execute(); |
|
|
|
$this->assertContains('Action class "userAction" not found.', $result); |
|
|
|
$error = file_get_contents($this->log_file_name); |
|
|
|
$this->assertContains('PHP Unknown Error: Action class "userAction" not found.', $error); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -170,11 +177,14 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase |
|
|
|
$this->getMock('userAction'); |
|
|
|
$_SERVER['REQUEST_URI'] = '/user/account/213'; |
|
|
|
$this->setConstants(true); |
|
|
|
ini_set('error_log', $this->log_file_name); |
|
|
|
$controller = FrontController::getInstance(); |
|
|
|
$router = $controller->getRouter(); |
|
|
|
$router->add('user', 'user/account/:id', 'user'); |
|
|
|
$result = $controller->execute(); |
|
|
|
$this->assertContains('Layout class "DefaultLayout" not found.', $result); |
|
|
|
$error = file_get_contents($this->log_file_name); |
|
|
|
$this->assertContains('PHP Unknown Error: Layout class "DefaultLayout" not found.', $error); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -267,6 +277,10 @@ class FrontControllerTest extends PHPUnit_Framework_TestCase |
|
|
|
public function tearDown() |
|
|
|
{ |
|
|
|
unset_new_overload(); |
|
|
|
if (file_exists($this->log_file_name) && is_writable($this->log_file_name)) { |
|
|
|
unlink($this->log_file_name); |
|
|
|
} |
|
|
|
ini_set('error_log', 'php://stderr'); |
|
|
|
} |
|
|
|
|
|
|
|
protected function newCallback($className) |
|
|
|