stderr = $this->getMock('ConsoleOutput', array(), array(), '', false); return $error; } /** * test that the console error handler can deal with CakeExceptions. * * @return void */ function testCakeErrors() { $exception = new MissingActionException('Missing action'); $error = $this->getErrorHandler($exception); $error->stderr->expects($this->once())->method('write') ->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->stderr->expects($this->once())->method('write') ->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->stderr->expects($this->once())->method('write') ->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->stderr->expects($this->once())->method('write') ->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->assertType('ConsoleOutput', $error->stderr, 'No handle.'); } }