diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index ca332bd8c0c..b9af5f1273e 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -218,14 +218,9 @@ function testExportVar() { $result = Debugger::exportVar($View); $expected = 'View View::$Helpers = HelperCollection object - View::$base = NULL - View::$here = NULL View::$plugin = NULL View::$name = "" - View::$action = NULL - View::$params = array View::$passedArgs = array - View::$data = array View::$helpers = array View::$viewPath = "" View::$viewVars = array @@ -247,7 +242,6 @@ function testExportVar() { View::$modelId = NULL View::$uuids = array View::$output = false - View::$webroot = NULL View::$request = NULL'; $result = str_replace(array("\t", "\r\n", "\n"), "", strtolower($result)); $expected = str_replace(array("\t", "\r\n", "\n"), "", strtolower($expected)); diff --git a/cake/tests/cases/libs/error_handler.test.php b/cake/tests/cases/libs/error_handler.test.php index a57de787d4b..c39e5055bb0 100644 --- a/cake/tests/cases/libs/error_handler.test.php +++ b/cake/tests/cases/libs/error_handler.test.php @@ -44,6 +44,7 @@ class AuthBlueberryUser extends CakeTestModel { */ public $useTable = false; } + if (!class_exists('AppController')) { /** * AppController class @@ -68,24 +69,6 @@ class AppController extends Controller { function beforeRender() { echo $this->Blueberry->testName; } - /** - * header method - * - * @access public - * @return void - */ - function header($header) { - echo $header; - } - /** - * _stop method - * - * @access public - * @return void - */ - function _stop($status = 0) { - echo 'Stopped with status: ' . $status; - } } } elseif (!defined('APP_CONTROLLER_EXISTS')){ define('APP_CONTROLLER_EXISTS', true); @@ -228,7 +211,17 @@ function setUp() { function teardown() { Configure::write('debug', $this->_debug); - } + } + +/** + * Mocks out the response on the errorhandler object so headers aren't modified. + * + * @return void + */ + protected function _mockResponse($error) { + $error->controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + return $error; + } /** * test handleException generating a page. @@ -239,6 +232,9 @@ function testHandleException() { if ($this->skipIf(file_exists(APP . 'app_error.php'), 'App error exists cannot run.')) { return; } + if ($this->skipIf(PHP_SAPI == 'cli', 'This integration test can not be run in cli.')) { + return; + } $error = new NotFoundException('Kaboom!'); ob_start(); ErrorHandler::handleException($error); @@ -256,7 +252,7 @@ function testSubclassMethodsNotBeingConvertedToError() { Configure::write('debug', 2); $exception = new MissingWidgetThingException('Widget not found'); - $ErrorHandler = new MyCustomErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception)); ob_start(); $ErrorHandler->render(); @@ -273,7 +269,7 @@ function testSubclassMethodsNotBeingConvertedToError() { function testSubclassMethodsNotBeingConvertedDebug0() { Configure::write('debug', 0); $exception = new MissingWidgetThingException('Widget not found'); - $ErrorHandler = new MyCustomErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception)); $this->assertEqual('missingWidgetThing', $ErrorHandler->method); @@ -293,7 +289,7 @@ function testSubclassConvertingFrameworkErrors() { Configure::write('debug', 0); $exception = new MissingControllerException('PostsController'); - $ErrorHandler = new MyCustomErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new MyCustomErrorHandler($exception)); $this->assertEqual('error400', $ErrorHandler->method); @@ -341,7 +337,7 @@ function testErrorMethodCoercion() { function testUnknownExceptionTypeWithExceptionThatHasA400Code() { $exception = new MissingWidgetThingException('coding fail.'); $ErrorHandler = new ErrorHandler($exception); - $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode')); + $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(404); ob_start(); @@ -360,7 +356,7 @@ function testUnknownExceptionTypeWithExceptionThatHasA400Code() { function testUnknownExceptionTypeWithNoCodeIsA500() { $exception = new OutOfBoundsException('foul ball.'); $ErrorHandler = new ErrorHandler($exception); - $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode')); + $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(500); ob_start(); @@ -387,7 +383,7 @@ function testerror400() { $exception = new NotFoundException('Custom message'); $ErrorHandler = new ErrorHandler($exception); - $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode')); + $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(404); ob_start(); @@ -409,7 +405,7 @@ function testerror400OnlyChangingCakeException() { Configure::write('debug', 0); $exception = new NotFoundException('Custom message'); - $ErrorHandler = new ErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception)); ob_start(); $ErrorHandler->render(); @@ -417,7 +413,7 @@ function testerror400OnlyChangingCakeException() { $this->assertContains('Custom message', $result); $exception = new MissingActionException(array('controller' => 'PostsController', 'action' => 'index')); - $ErrorHandler = new ErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception)); ob_start(); $ErrorHandler->render(); @@ -436,7 +432,7 @@ function testError400NoInjection() { Router::setRequestInfo($request); $exception = new NotFoundException('Custom message'); - $ErrorHandler = new ErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception)); ob_start(); $ErrorHandler->render(); @@ -455,7 +451,7 @@ function testError400NoInjection() { function testError500Message() { $exception = new InternalErrorException('An Internal Error Has Occurred'); $ErrorHandler = new ErrorHandler($exception); - $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode')); + $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ErrorHandler->controller->response->expects($this->once())->method('statusCode')->with(500); ob_start(); @@ -475,7 +471,7 @@ function testMissingController() { $this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController'); $exception = new MissingControllerException(array('controller' => 'PostsController')); - $ErrorHandler = new ErrorHandler($exception); + $ErrorHandler = $this->_mockResponse(new ErrorHandler($exception)); ob_start(); $ErrorHandler->render(); @@ -624,7 +620,7 @@ public static function testProvider() { */ function testCakeExceptionHandling($exception, $patterns, $code) { $ErrorHandler = new ErrorHandler($exception); - $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode')); + $ErrorHandler->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); $ErrorHandler->controller->response->expects($this->once()) ->method('statusCode') ->with($code);