| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | class CakeHtmlReporter extends SimpleReporter { |
|---|
| 34 | var $_character_set; |
|---|
| 35 | var $_show_passes = false; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | function CakeHtmlReporter($character_set = 'ISO-8859-1') { |
|---|
| 43 | if (isset($_GET['show_passes']) && $_GET['show_passes']) { |
|---|
| 44 | $this->_show_passes = true; |
|---|
| 45 | } |
|---|
| 46 | $this->SimpleReporter(); |
|---|
| 47 | $this->_character_set = $character_set; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | function paintHeader($testName) { |
|---|
| 56 | $this->sendNoCacheHeaders(); |
|---|
| 57 | echo "<h2>$testName</h2>\n"; |
|---|
| 58 | echo "<ul class='tests'>\n"; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | function sendNoCacheHeaders() { |
|---|
| 68 | if (!headers_sent()) { |
|---|
| 69 | header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); |
|---|
| 70 | header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|---|
| 71 | header("Cache-Control: no-store, no-cache, must-revalidate"); |
|---|
| 72 | header("Cache-Control: post-check=0, pre-check=0", false); |
|---|
| 73 | header("Pragma: no-cache"); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | function paintFooter($test_name) { |
|---|
| 83 | $colour = ($this->getFailCount() + $this->getExceptionCount() > 0 ? "red" : "green"); |
|---|
| 84 | echo "</ul>\n"; |
|---|
| 85 | echo "<div style=\""; |
|---|
| 86 | echo "padding: 8px; margin: 1em 0; background-color: $colour; color: white;"; |
|---|
| 87 | echo "\">"; |
|---|
| 88 | echo $this->getTestCaseProgress() . "/" . $this->getTestCaseCount(); |
|---|
| 89 | echo " test cases complete:\n"; |
|---|
| 90 | echo "<strong>" . $this->getPassCount() . "</strong> passes, "; |
|---|
| 91 | echo "<strong>" . $this->getFailCount() . "</strong> fails and "; |
|---|
| 92 | echo "<strong>" . $this->getExceptionCount() . "</strong> exceptions."; |
|---|
| 93 | echo "</div>\n"; |
|---|
| 94 | echo "</body>\n</html>\n"; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | function paintFail($message) { |
|---|
| 105 | parent::paintFail($message); |
|---|
| 106 | echo "<li class='fail'>\n"; |
|---|
| 107 | echo "<span>Failed</span>"; |
|---|
| 108 | echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n"; |
|---|
| 109 | $breadcrumb = Set::filter($this->getTestList()); |
|---|
| 110 | array_shift($breadcrumb); |
|---|
| 111 | echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n"; |
|---|
| 112 | echo "</li>\n"; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | function paintPass($message) { |
|---|
| 123 | parent::paintPass($message); |
|---|
| 124 | |
|---|
| 125 | if ($this->_show_passes) { |
|---|
| 126 | echo "<li class='pass'>\n"; |
|---|
| 127 | echo "<span>Passed</span> "; |
|---|
| 128 | $breadcrumb = Set::filter($this->getTestList()); |
|---|
| 129 | array_shift($breadcrumb); |
|---|
| 130 | echo implode(" -> ", $breadcrumb); |
|---|
| 131 | echo "<br />" . $this->_htmlEntities($message) . "\n"; |
|---|
| 132 | echo "</li>\n"; |
|---|
| 133 | } |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | |
|---|
| 139 | |
|---|
| 140 | function paintError($message) { |
|---|
| 141 | parent::paintError($message); |
|---|
| 142 | echo "<li class='error'>\n"; |
|---|
| 143 | echo "<span>Error</span>"; |
|---|
| 144 | echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n"; |
|---|
| 145 | $breadcrumb = Set::filter($this->getTestList()); |
|---|
| 146 | array_shift($breadcrumb); |
|---|
| 147 | echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n"; |
|---|
| 148 | echo "</li>\n"; |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|
| 155 | function paintException($exception) { |
|---|
| 156 | parent::paintException($exception); |
|---|
| 157 | echo "<li class='fail'>\n"; |
|---|
| 158 | echo "<span>Exception</span>"; |
|---|
| 159 | $message = 'Unexpected exception of type [' . get_class($exception) . |
|---|
| 160 | '] with message ['. $exception->getMessage() . |
|---|
| 161 | '] in ['. $exception->getFile() . |
|---|
| 162 | ' line ' . $exception->getLine() . ']'; |
|---|
| 163 | echo "<div class='msg'>" . $this->_htmlEntities($message) . "</div>\n"; |
|---|
| 164 | $breadcrumb = Set::filter($this->getTestList()); |
|---|
| 165 | array_shift($breadcrumb); |
|---|
| 166 | echo "<div>" . implode(" -> ", $breadcrumb) . "</div>\n"; |
|---|
| 167 | echo "</li>\n"; |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | function paintSkip($message) { |
|---|
| 175 | parent::paintSkip($message); |
|---|
| 176 | echo "<li class='skipped'>\n"; |
|---|
| 177 | echo "<span>Skipped</span> "; |
|---|
| 178 | echo $this->_htmlEntities($message); |
|---|
| 179 | echo "</li>\n"; |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | |
|---|
| 185 | |
|---|
| 186 | function paintFormattedMessage($message) { |
|---|
| 187 | echo '<pre>' . $this->_htmlEntities($message) . '</pre>'; |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | function _htmlEntities($message) { |
|---|
| 196 | return htmlentities($message, ENT_COMPAT, $this->_character_set); |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | ?> |
|---|