2007-07-09 19:26:37 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
2008-01-01 22:18:17 +00:00
|
|
|
* Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 19:26:37 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2008-01-01 22:18:17 +00:00
|
|
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 19:26:37 +00:00
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5432
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
2008-02-27 21:22:40 +00:00
|
|
|
App::import('Core', array('Error', 'Controller'));
|
|
|
|
|
2008-02-15 16:49:17 +00:00
|
|
|
if (!defined('CAKEPHP_UNIT_TEST_EXECUTION')) {
|
|
|
|
define('CAKEPHP_UNIT_TEST_EXECUTION', 1);
|
|
|
|
}
|
2008-02-27 21:22:40 +00:00
|
|
|
|
2008-02-15 16:49:17 +00:00
|
|
|
if (!class_exists('TestAppController')) {
|
|
|
|
class TestAppController extends Controller {
|
|
|
|
function beforeFilter() {
|
|
|
|
$this->cakeError('error404', array('oops' => 'Nothing to see here'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class TestErrorController extends TestAppController {
|
|
|
|
|
|
|
|
var $uses = array();
|
|
|
|
|
|
|
|
function index() {
|
|
|
|
$this->autoRender = false;
|
|
|
|
return 'what up';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2007-07-09 19:26:37 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs
|
|
|
|
*/
|
|
|
|
class ErrorHandlerTest extends UnitTestCase {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-07-09 19:26:37 +00:00
|
|
|
function skip() {
|
2008-02-15 16:49:17 +00:00
|
|
|
$this->skipif (false, 'ErrorHandlerTest not implemented');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testFromBeforeFilter() {
|
|
|
|
$Test = new TestErrorController();
|
|
|
|
|
|
|
|
if (!class_exists('dispatcher')) {
|
|
|
|
require CAKE . 'dispatcher.php';
|
|
|
|
}
|
|
|
|
$Dispatcher =& new Dispatcher();
|
|
|
|
|
|
|
|
restore_error_handler();
|
|
|
|
ob_start();
|
|
|
|
$controller = $Dispatcher->dispatch('/test_error', array('return'=> 1));
|
|
|
|
$expected = ob_get_clean();
|
|
|
|
set_error_handler('simpleTestErrorHandler');
|
|
|
|
$this->assertPattern("/<h2>Not Found<\/h2>/", $expected);
|
|
|
|
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $expected);
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testError() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testError404() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingController() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingAction() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testPrivateAction() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingTable() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingDatabase() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingView() {
|
2008-02-27 21:22:40 +00:00
|
|
|
restore_error_handler();
|
|
|
|
ob_start();
|
|
|
|
$ErrorHandler = new ErrorHandler('missingView', array(
|
|
|
|
'className' => 'Pages',
|
|
|
|
'action' => 'display',
|
|
|
|
'file' => 'pages/about.ctp',
|
|
|
|
'base' => ''
|
|
|
|
));
|
|
|
|
$expected = ob_get_clean();
|
|
|
|
set_error_handler('simpleTestErrorHandler');
|
|
|
|
$this->assertPattern("/PagesController::/", $expected);
|
|
|
|
$this->assertPattern("/pages\/about.ctp/", $expected);
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingLayout() {
|
2008-02-27 21:22:40 +00:00
|
|
|
restore_error_handler();
|
|
|
|
ob_start();
|
|
|
|
$ErrorHandler = new ErrorHandler('missingLayout', array(
|
|
|
|
'layout' => 'my_layout',
|
|
|
|
'file' => 'layouts/my_layout.ctp',
|
|
|
|
'base' => ''
|
|
|
|
));
|
|
|
|
$expected = ob_get_clean();
|
|
|
|
set_error_handler('simpleTestErrorHandler');
|
|
|
|
$this->assertPattern("/Missing Layout/", $expected);
|
|
|
|
$this->assertPattern("/layouts\/my_layout.ctp/", $expected);
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingConnection() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingHelperFile() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingHelperClass() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingComponentFile() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingComponentClass() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
}
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-11-04 07:03:57 +00:00
|
|
|
function testMissingModel() {
|
2008-01-01 22:18:17 +00:00
|
|
|
|
2007-07-09 19:26:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|