getMock('ConsoleErrorHandler', array('stderr'), array($exception)); } /** * test that the console error handler can deal with CakeExceptions. * * @return void */ function testCakeErrors() { $exception = new MissingActionException('Missing action'); $error = $this->getErrorHandler($exception); $error->expects($this->once())->method('stderr') ->with($this->stringContains('Missing action')); $error->render(); } /** * test a non CakeException exception. * * @return void */ function testNonCakeExceptions() { $exception = new InvalidArgumentException('Too many parameters.'); $error = $this->getErrorHandler($exception); $error->expects($this->once())->method('stderr') ->with($this->stringContains('Too many parameters.')); $error->render(); } /** * test a Error404 exception. * * @return void */ function testError404Exception() { $exception = new NotFoundException('dont use me in cli.'); $error = $this->getErrorHandler($exception); $error->expects($this->once())->method('stderr') ->with($this->stringContains('dont use me in cli.')); $error->render(); } /** * test a Error500 exception. * * @return void */ function testError500Exception() { $exception = new InternalErrorException('dont use me in cli.'); $error = $this->getErrorHandler($exception); $error->expects($this->once())->method('stderr') ->with($this->stringContains('dont use me in cli.')); $error->render(); } /** * test that ConsoleErrorHandler has a stderr file handle. * * @return void */ function testStdErrFilehandle() { $exception = new InternalErrorException('dont use me in cli.'); $error = new ConsoleErrorHandler($exception); $this->assertTrue(is_resource($error->stderr), 'No handle.'); } }