mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +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
|
||||
* @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("/<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 @@ 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('/<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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue