1: <?php
2: /**
3: * A test helper for testing Horde_Cli based classes.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Test
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL
11: * @link http://www.horde.org/components/Horde_Test
12: */
13:
14: /**
15: * A test helper for testing Horde_Cli based classes.
16: *
17: * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you
20: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
21: *
22: * @since Horde_Test 1.2.0
23: *
24: * @category Horde
25: * @package Test
26: * @author Gunnar Wrobel <wrobel@pardus.de>
27: * @license http://www.horde.org/licenses/lgpl21 LGPL
28: * @link http://www.horde.org/components/Horde_Test
29: */
30: class Horde_Test_Stub_Cli extends Horde_Cli
31: {
32: /**
33: * Displays a fatal error message.
34: *
35: * @param mixed $error The error text to display, an exception or an
36: * object with a getMessage() method.
37: */
38: public function fatal($error)
39: {
40: if ($error instanceof Exception) {
41: $trace = $error;
42: } else {
43: $trace = debug_backtrace();
44: }
45: $backtrace = new Horde_Support_Backtrace($trace);
46: if (is_object($error) && method_exists($error, 'getMessage')) {
47: $error = $error->getMessage();
48: }
49: $this->writeln($this->red('===================='));
50: $this->writeln();
51: $this->writeln($this->red('Fatal Error:'));
52: $this->writeln($this->red($error));
53: $this->writeln();
54: $this->writeln((string)$backtrace);
55: $this->writeln($this->red('===================='));
56: }
57: }