Skip to content
Permalink
Browse files

Removing AppController from ErrorHandler test as it can make testing …

…harder.

Removing broken buffering from tests that trigger errors / exceptions.
Adding a loadHelper() to the test_app layout so the layout always has the required helper.
  • Loading branch information...
markstory committed Sep 25, 2010
1 parent 714d829 commit 843ada240adcdbeecafbeb2391212f907738c312
@@ -45,35 +45,6 @@ class AuthBlueberryUser extends CakeTestModel {
public $useTable = false;
}
if (!class_exists('AppController')) {
/**
* AppController class
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class AppController extends Controller {
/**
* components property
*
* @access public
* @return void
*/
public $components = array('Blueberry');
/**
* beforeRender method
*
* @access public
* @return void
*/
function beforeRender() {
echo $this->Blueberry->testName;
}
}
} elseif (!defined('APP_CONTROLLER_EXISTS')){
define('APP_CONTROLLER_EXISTS', true);
}
/**
* BlueberryComponent class
*
@@ -107,7 +78,7 @@ function initialize(&$controller) {
* @package cake
* @subpackage cake.tests.cases.libs
*/
class TestErrorController extends AppController {
class TestErrorController extends Controller {
/**
* uses property
@@ -118,40 +89,33 @@ class TestErrorController extends AppController {
public $uses = array();
/**
* index method
* components property
*
* @access public
* @return void
*/
function index() {
$this->autoRender = false;
return 'what up';
}
}
public $components = array('Blueberry');
/**
* BlueberryController class
*
* @package cake
* @subpackage cake.tests.cases.libs
*/
class BlueberryController extends AppController {
/**
* name property
* beforeRender method
*
* @access public
* @return void
*/
public $name = 'BlueberryController';
function beforeRender() {
echo $this->Blueberry->testName;
}
/**
* uses property
* index method
*
* @access public
* @return void
*/
public $uses = array();
function index() {
$this->autoRender = false;
return 'what up';
}
}
/**
@@ -187,30 +151,34 @@ class MissingWidgetThingException extends NotFoundException { }
*/
class ErrorHandlerTest extends CakeTestCase {
/**
* skip method
*
* @access public
* @return void
*/
function skip() {
$this->skipIf(PHP_SAPI === 'cli', '%s Cannot be run from console');
}
/**
* setup create a request object to get out of router later.
*
* @return void
*/
function setUp() {
App::build(array(
'views' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS
)
), true);
Router::reload();
$request = new CakeRequest(null, false);
$request->base = '';
Router::setRequestInfo($request);
$this->_debug = Configure::read('debug');
}
/**
* teardown
*
* @return void
*/
function teardown() {
Configure::write('debug', $this->_debug);
App::build();
}
/**
@@ -372,10 +340,7 @@ function testUnknownExceptionTypeWithNoCodeIsA500() {
* @access public
* @return void
*/
function testerror400() {
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)
), true);
function testError400() {
Router::reload();
$request = new CakeRequest('posts/view/1000', false);
@@ -392,8 +357,6 @@ function testerror400() {
$this->assertPattern('/<h2>Custom message<\/h2>/', $result);
$this->assertPattern("/<strong>'\/posts\/view\/1000'<\/strong>/", $result);
App::build();
}
/**
@@ -468,8 +431,6 @@ function testError500Message() {
* @return void
*/
function testMissingController() {
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController');
$exception = new MissingControllerException(array('controller' => 'PostsController'));
$ErrorHandler = $this->_mockResponse(new ErrorHandler($exception));
@@ -479,20 +440,8 @@ function testMissingController() {
$this->assertPattern('/<h2>Missing Controller<\/h2>/', $result);
$this->assertPattern('/<em>PostsController<\/em>/', $result);
$this->assertPattern('/BlueberryComponent/', $result);
}
/* TODO: Integration test that needs to be moved
ob_start();
$dispatcher = new Dispatcher('/blueberry/inexistent');
$result = ob_get_clean();
$this->assertPattern('/<h2>Missing Method in BlueberryController<\/h2>/', $result);
$this->assertPattern('/<em>BlueberryController::<\/em><em>inexistent\(\)<\/em>/', $result);
$this->assertNoPattern('/Location: (.*)\/users\/login/', $result);
$this->assertNoPattern('/Stopped with status: 0/', $result);
*/
/**
* Returns an array of tests to run for the various CakeException classes.
*
@@ -4243,16 +4243,6 @@ function testShowQuery() {
$this->assertPattern('/Aff:/s', $contents);
$this->assertPattern('/Num:/s', $contents);
$this->assertPattern('/Took:/s', $contents);
$this->expectError();
$this->testDb->error = true;
ob_start();
$this->testDb->showQuery('Another Query');
$contents = ob_get_clean();
$this->assertPattern('/Another Query/s', $contents);
$this->assertNoPattern('/Aff:/s', $contents);
$this->assertNoPattern('/Num:/s', $contents);
$this->assertNoPattern('/Took:/s', $contents);
}
/**
@@ -16,6 +16,7 @@
* @since CakePHP(tm) v 0.10.0.1076
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
$this->loadHelper('Html');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -26,8 +27,6 @@
<?php echo $title_for_layout;?>
</title>

<link rel="icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="<?php echo $this->webroot;?>favicon.ico" type="image/x-icon" />
<?php echo $this->Html->css('cake.generic');?>
<?php echo $scripts_for_layout;?>
</head>

0 comments on commit 843ada2

Please sign in to comment.
You can’t perform that action at this time.