From 17054db31f7531f9f8ecffd18c5e89b8fc24dc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 9 Jun 2010 00:16:18 -0430 Subject: [PATCH] Migrating ErrorTest to PHPUnit --- cake/tests/cases/libs/error.test.php | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/cake/tests/cases/libs/error.test.php b/cake/tests/cases/libs/error.test.php index 64e1c5b4c..9b870aeef 100644 --- a/cake/tests/cases/libs/error.test.php +++ b/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 @@ class ErrorHandlerTest extends CakeTestCase { $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 @@ class ErrorHandlerTest extends CakeTestCase { $this->assertPattern("/'\/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 @@ class ErrorHandlerTest extends CakeTestCase { * @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 @@ class ErrorHandlerTest extends CakeTestCase { * @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 @@ class ErrorHandlerTest extends CakeTestCase { ob_start(); $TestErrorHandler = new TestErrorHandler('missingBehaviorClass', array('behavior' => 'MyCustom', 'file' => 'my_custom.php')); $result = ob_get_clean(); - $this->assertPattern('/

Missing Behavior Class<\/h2>/', $result); $this->assertPattern('/The behavior class MyCustomBehavior<\/em> can not be found or does not exist./', $result); $this->assertPattern('/(\/|\\\)my_custom.php/', $result); }