mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Migrating ErrorTest to PHPUnit
This commit is contained in:
parent
b5539542a1
commit
17054db31f
1 changed files with 5 additions and 18 deletions
|
@ -193,15 +193,7 @@ class BlueberryController extends AppController {
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public $uses = array('AuthBlueberryUser');
|
public $uses = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* components property
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public $components = array('Auth');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,19 +271,19 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
$back = Configure::read('debug');
|
$back = Configure::read('debug');
|
||||||
Configure::write('debug', 2);
|
Configure::write('debug', 2);
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler =& new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
|
$ErrorHandler = new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertEqual($result, 'widget thing is missing');
|
$this->assertEqual($result, 'widget thing is missing');
|
||||||
|
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler =& new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
|
$ErrorHandler = new MyCustomErrorHandler('missingWidgetThing', array('message' => 'doh!'));
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertEqual($result, 'widget thing is missing', 'Method declared in subclass converted to error404. %s');
|
$this->assertEqual($result, 'widget thing is missing', 'Method declared in subclass converted to error404. %s');
|
||||||
|
|
||||||
Configure::write('debug', 0);
|
Configure::write('debug', 0);
|
||||||
ob_start();
|
ob_start();
|
||||||
$ErrorHandler =& new MyCustomErrorHandler('missingController', array(
|
$ErrorHandler = new MyCustomErrorHandler('missingController', array(
|
||||||
'className' => 'Missing', 'message' => 'Page not found'
|
'className' => 'Missing', 'message' => 'Page not found'
|
||||||
));
|
));
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
|
@ -339,7 +331,7 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
|
$this->assertPattern("/<strong>'\/test_error'<\/strong>/", $result);
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$TestErrorHandler =& new TestErrorHandler('error404', array('message' => 'Page not found'));
|
$TestErrorHandler = new TestErrorHandler('error404', array('message' => 'Page not found'));
|
||||||
ob_get_clean();
|
ob_get_clean();
|
||||||
ob_start();
|
ob_start();
|
||||||
$TestErrorHandler->error404(array(
|
$TestErrorHandler->error404(array(
|
||||||
|
@ -466,11 +458,9 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testMissingView() {
|
function testMissingView() {
|
||||||
restore_error_handler();
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$TestErrorHandler = new TestErrorHandler('missingView', array('className' => 'Pages', 'action' => 'display', 'file' => 'pages/about.ctp', 'base' => ''));
|
$TestErrorHandler = new TestErrorHandler('missingView', array('className' => 'Pages', 'action' => 'display', 'file' => 'pages/about.ctp', 'base' => ''));
|
||||||
$expected = ob_get_clean();
|
$expected = ob_get_clean();
|
||||||
set_error_handler('simpleTestErrorHandler');
|
|
||||||
$this->assertPattern("/PagesController::/", $expected);
|
$this->assertPattern("/PagesController::/", $expected);
|
||||||
$this->assertPattern("/pages\/about.ctp/", $expected);
|
$this->assertPattern("/pages\/about.ctp/", $expected);
|
||||||
}
|
}
|
||||||
|
@ -482,11 +472,9 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testMissingLayout() {
|
function testMissingLayout() {
|
||||||
restore_error_handler();
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$TestErrorHandler = new TestErrorHandler('missingLayout', array( 'layout' => 'my_layout', 'file' => 'layouts/my_layout.ctp', 'base' => ''));
|
$TestErrorHandler = new TestErrorHandler('missingLayout', array( 'layout' => 'my_layout', 'file' => 'layouts/my_layout.ctp', 'base' => ''));
|
||||||
$expected = ob_get_clean();
|
$expected = ob_get_clean();
|
||||||
set_error_handler('simpleTestErrorHandler');
|
|
||||||
$this->assertPattern("/Missing Layout/", $expected);
|
$this->assertPattern("/Missing Layout/", $expected);
|
||||||
$this->assertPattern("/layouts\/my_layout.ctp/", $expected);
|
$this->assertPattern("/layouts\/my_layout.ctp/", $expected);
|
||||||
}
|
}
|
||||||
|
@ -560,7 +548,6 @@ class ErrorHandlerTest extends CakeTestCase {
|
||||||
ob_start();
|
ob_start();
|
||||||
$TestErrorHandler = new TestErrorHandler('missingBehaviorClass', array('behavior' => 'MyCustom', 'file' => 'my_custom.php'));
|
$TestErrorHandler = new TestErrorHandler('missingBehaviorClass', array('behavior' => 'MyCustom', 'file' => 'my_custom.php'));
|
||||||
$result = ob_get_clean();
|
$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('/The behavior class <em>MyCustomBehavior<\/em> can not be found or does not exist./', $result);
|
||||||
$this->assertPattern('/(\/|\\\)my_custom.php/', $result);
|
$this->assertPattern('/(\/|\\\)my_custom.php/', $result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue