Skip to content
Permalink
Browse files

Migrating ErrorTest to PHPUnit

  • Loading branch information...
lorenzo committed Jun 9, 2010
1 parent b553954 commit 17054db31f7531f9f8ecffd18c5e89b8fc24dc27
Showing with 5 additions and 18 deletions.
  1. +5 −18 cake/tests/cases/libs/error.test.php
@@ -193,15 +193,7 @@ class BlueberryController extends AppController {
* @access public
* @return void
*/
public $uses = array('AuthBlueberryUser');
/**
* components property
*
* @access public
* @return void
*/
public $components = array('Auth');
public $uses = array();
}
/**
@@ -279,19 +271,19 @@ function testSubclassMethodsNotBeingConvertedToError() {
$back = Configure::read('debug');
Configure::write('debug', 2);
ob_start();
$ErrorHandler =& new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
$ErrorHandler = new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
$result = ob_get_clean();
$this->assertEqual($result, 'widget thing is missing');
Configure::write('debug', 0);
ob_start();
$ErrorHandler =& new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
$ErrorHandler = new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
$result = ob_get_clean();
$this->assertEqual($result, 'widget thing is missing', 'Method declared in subclass converted to error404. %s');
Configure::write('debug', 0);
ob_start();
$ErrorHandler =& new MyCustomErrorHandler('missingController', array(
$ErrorHandler = new MyCustomErrorHandler('missingController', array(
'className' => 'Missing', 'message' => 'Page not found'
));
$result = ob_get_clean();
@@ -339,7 +331,7 @@ function testError404() {
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
ob_start();
$TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found'));
$TestErrorHandler = new TestErrorHandler('error404', array('message' => 'Page not found'));
ob_get_clean();
ob_start();
$TestErrorHandler->error404(array(
@@ -466,11 +458,9 @@ function testMissingDatabase() {
* @return void
*/
function testMissingView() {
restore_error_handler();
ob_start();
$TestErrorHandler = new TestErrorHandler('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);
}
@@ -482,11 +472,9 @@ function testMissingView() {
* @return void
*/
function testMissingLayout() {
restore_error_handler();
ob_start();
$TestErrorHandler = new TestErrorHandler('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);
}
@@ -560,7 +548,6 @@ function testMissingBehaviorClass() {
ob_start();
$TestErrorHandler = new TestErrorHandler('missingBehaviorClass', array('behavior' => 'MyCustom', 'file' => 'my_custom.php'));
$result = ob_get_clean();
$this->assertPattern('/<h2>Missing Behavior Class<\/h2>/', $result);
$this->assertPattern('/The behavior class <em>MyCustomBehavior<\/em> can not be found or does not exist./', $result);
$this->assertPattern('/(\/|\\\)my_custom.php/', $result);
}

0 comments on commit 17054db

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