3 * Ethna_UnitTestReporter.php
5 * @author Takuya Ookubo <sfio@sakura.ai.to>
6 * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
11 require_once 'simpletest/scorer.php';
16 * @author Takuya Ookubo <sfio@sakura.ai.to>
20 class Ethna_UnitTestReporter extends SimpleReporter {
28 * Ethna_UnitTestReporterのコンストラクタ
31 * @param string $character_set キャラクタセット
33 function Ethna_UnitTestReporter($character_set = 'EUC-JP')
35 $this->SimpleReporter();
36 $this->_character_set = $character_set;
37 $this->report= array();
38 $this->result= array();
45 * @param string $test_name テスト名称
47 function paintFooter($test_name)
49 $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green");
50 $this->result = array(
51 'TestCaseProgress' => $this->getTestCaseProgress(),
52 'TestCaseCount' => $this->getTestCaseCount(),
53 'PassCount' => $this->getPassCount(),
54 'FailCount' => $this->getFailCount(),
55 'ExceptionCount' => $this->getExceptionCount(),
63 * @param string $message メッセージ
65 function paintPass($message)
67 parent::paintPass($message);
69 $test_list = $this->getTestList();
70 $this->report[] = array(
72 'test' => $test_list[2],
73 'message' => $message,
81 * @param string $message メッセージ
83 function paintFail($message)
85 parent::paintFail($message);
87 $test_list = $this->getTestList();
88 $this->report[] = array(
90 'test' => $test_list[2],
91 'message' => $message,
99 * @param string $message メッセージ
101 function paintException($message)
103 parent::paintException($message);
105 $breadcrumb = $this->getTestList();
106 $test = $breadcrumb[2];
107 array_shift($breadcrumb);
108 $this->report[] = array(
109 'type' => 'Exception',
111 'breadcrumb' => $breadcrumb,
112 'message' => $message,
120 * @param string $test_name テスト名称
122 function paintCaseStart($test_name)
124 parent::paintCaseStart($test_name);
126 $this->report[] = array(
127 'type' => 'CaseStart',
128 'test_name' => $test_name,
136 * @param string $test_name テスト名称
138 function paintCaseEnd($test_name)
140 parent::paintCaseEnd($test_name);
142 $this->report[] = array(
151 * @param string $message メッセージ
153 function paintFormattedMessage($message)
155 $this->report[] = array(
156 'type' => 'FormattedMessage',
157 'message' => $this->_htmlEntities($message),
165 * @param string $message プレーンテキスト
166 * @return string HTMLエンティティ変換済みメッセージ
168 function _htmlEntities($message)
170 return htmlentities($message, ENT_COMPAT, $this->_character_set);