getMock('ConsoleOutput', array(), array(), '', false); } /** * teardown * * @return void */ function tearDown() { parent::tearDown(); ConsoleErrorHandler::$stderr = null; } /** * test that the console error handler can deal with CakeExceptions. * * @return void */ function testHandleError() { $content = 'Notice Error: This is a notice error in [/some/file, line 275]'; ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($content); ConsoleErrorHandler::handleError(E_NOTICE, 'This is a notice error', '/some/file', 275); } /** * test that the console error handler can deal with CakeExceptions. * * @return void */ function testCakeErrors() { $exception = new MissingActionException('Missing action'); ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($this->stringContains('Missing action')); ConsoleErrorHandler::handleException($exception); } /** * test a non CakeException exception. * * @return void */ function testNonCakeExceptions() { $exception = new InvalidArgumentException('Too many parameters.'); ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($this->stringContains('Too many parameters.')); ConsoleErrorHandler::handleException($exception); } /** * test a Error404 exception. * * @return void */ function testError404Exception() { $exception = new NotFoundException('dont use me in cli.'); ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($this->stringContains('dont use me in cli.')); ConsoleErrorHandler::handleException($exception); } /** * test a Error500 exception. * * @return void */ function testError500Exception() { $exception = new InternalErrorException('dont use me in cli.'); ConsoleErrorHandler::$stderr->expects($this->once())->method('write') ->with($this->stringContains('dont use me in cli.')); ConsoleErrorHandler::handleException($exception); } }