output[] = $line; } } /** * ConsoleErrorHandler Test case. * * @package cake.tests.cases.console */ class ConsoleErrorHandlerTest extends CakeTestCase { /** * test that the console error handler can deal with CakeExceptions. * * @return void */ function testCakeErrors() { $exception = new MissingActionException('Missing action'); $error = new TestConsoleErrorHandler($exception); $error->render(); $result = $error->output; $this->assertEquals(1, count($result)); $this->assertEquals('Missing action', $result[0]); } /** * test a non CakeException exception. * * @return void */ function testNonCakeExceptions() { $exception = new InvalidArgumentException('Too many parameters.'); $error = new TestConsoleErrorHandler($exception); $error->render(); $result = $error->output; $this->assertEquals(1, count($result)); $this->assertEquals('Too many parameters.', $result[0]); } /** * test a Error404 exception. * * @return void */ function testError404Exception() { $exception = new Error404Exception('dont use me in cli.'); $error = new TestConsoleErrorHandler($exception); $error->render(); $result = $error->output; $this->assertEquals(1, count($result)); $this->assertEquals('dont use me in cli.', $result[0]); } /** * test a Error500 exception. * * @return void */ function testError500Exception() { $exception = new Error500Exception('dont use me in cli.'); $error = new TestConsoleErrorHandler($exception); $error->render(); $result = $error->output; $this->assertEquals(1, count($result)); $this->assertEquals('dont use me in cli.', $result[0]); } /** * test that ConsoleErrorHandler has a stderr file handle. * * @return void */ function testStdErrFilehandle() { $exception = new Error500Exception('dont use me in cli.'); $error = new TestConsoleErrorHandler($exception); $this->assertTrue(is_resource($error->stderr), 'No handle.'); } }