|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00010 require_once(dirname(__FILE__) . '/invoker.php'); 00021 class SimpleScorer { 00022 var $_passes; 00023 var $_fails; 00024 var $_exceptions; 00025 var $_is_dry_run; 00026 00031 function SimpleScorer() { 00032 $this->_passes = 0; 00033 $this->_fails = 0; 00034 $this->_exceptions = 0; 00035 $this->_is_dry_run = false; 00036 } 00037 00045 function makeDry($is_dry = true) { 00046 $this->_is_dry_run = $is_dry; 00047 } 00048 00055 function shouldInvoke($test_case_name, $method) { 00056 return ! $this->_is_dry_run; 00057 } 00058 00066 function &createInvoker(&$invoker) { 00067 return $invoker; 00068 } 00069 00077 function getStatus() { 00078 if ($this->_exceptions + $this->_fails > 0) { 00079 return false; 00080 } 00081 return true; 00082 } 00083 00090 function paintGroupStart($test_name, $size) { 00091 } 00092 00098 function paintGroupEnd($test_name) { 00099 } 00100 00106 function paintCaseStart($test_name) { 00107 } 00108 00114 function paintCaseEnd($test_name) { 00115 } 00116 00122 function paintMethodStart($test_name) { 00123 } 00124 00130 function paintMethodEnd($test_name) { 00131 } 00132 00138 function paintPass($message) { 00139 $this->_passes++; 00140 } 00141 00147 function paintFail($message) { 00148 $this->_fails++; 00149 } 00150 00157 function paintError($message) { 00158 $this->_exceptions++; 00159 } 00160 00166 function paintException($exception) { 00167 $this->_exceptions++; 00168 } 00169 00175 function paintSkip($message) { 00176 } 00177 00183 function getPassCount() { 00184 return $this->_passes; 00185 } 00186 00192 function getFailCount() { 00193 return $this->_fails; 00194 } 00195 00202 function getExceptionCount() { 00203 return $this->_exceptions; 00204 } 00205 00211 function paintMessage($message) { 00212 } 00213 00220 function paintFormattedMessage($message) { 00221 } 00222 00229 function paintSignal($type, $payload) { 00230 } 00231 } 00232 00241 class SimpleReporter extends SimpleScorer { 00242 var $_test_stack; 00243 var $_size; 00244 var $_progress; 00245 00250 function SimpleReporter() { 00251 $this->SimpleScorer(); 00252 $this->_test_stack = array(); 00253 $this->_size = null; 00254 $this->_progress = 0; 00255 } 00256 00263 function getDumper() { 00264 return new SimpleDumper(); 00265 } 00266 00276 function paintGroupStart($test_name, $size) { 00277 if (! isset($this->_size)) { 00278 $this->_size = $size; 00279 } 00280 if (count($this->_test_stack) == 0) { 00281 $this->paintHeader($test_name); 00282 } 00283 $this->_test_stack[] = $test_name; 00284 } 00285 00293 function paintGroupEnd($test_name) { 00294 array_pop($this->_test_stack); 00295 if (count($this->_test_stack) == 0) { 00296 $this->paintFooter($test_name); 00297 } 00298 } 00299 00308 function paintCaseStart($test_name) { 00309 if (! isset($this->_size)) { 00310 $this->_size = 1; 00311 } 00312 if (count($this->_test_stack) == 0) { 00313 $this->paintHeader($test_name); 00314 } 00315 $this->_test_stack[] = $test_name; 00316 } 00317 00324 function paintCaseEnd($test_name) { 00325 $this->_progress++; 00326 array_pop($this->_test_stack); 00327 if (count($this->_test_stack) == 0) { 00328 $this->paintFooter($test_name); 00329 } 00330 } 00331 00337 function paintMethodStart($test_name) { 00338 $this->_test_stack[] = $test_name; 00339 } 00340 00347 function paintMethodEnd($test_name) { 00348 array_pop($this->_test_stack); 00349 } 00350 00358 function paintHeader($test_name) { 00359 } 00360 00367 function paintFooter($test_name) { 00368 } 00369 00377 function getTestList() { 00378 return $this->_test_stack; 00379 } 00380 00388 function getTestCaseCount() { 00389 return $this->_size; 00390 } 00391 00398 function getTestCaseProgress() { 00399 return $this->_progress; 00400 } 00401 00408 function inCli() { 00409 return php_sapi_name() == 'cli'; 00410 } 00411 } 00412 00418 class SimpleReporterDecorator { 00419 var $_reporter; 00420 00425 function SimpleReporterDecorator(&$reporter) { 00426 $this->_reporter = &$reporter; 00427 } 00428 00436 function makeDry($is_dry = true) { 00437 $this->_reporter->makeDry($is_dry); 00438 } 00439 00447 function getStatus() { 00448 return $this->_reporter->getStatus(); 00449 } 00450 00458 function shouldInvoke($test_case_name, $method) { 00459 return $this->_reporter->shouldInvoke($test_case_name, $method); 00460 } 00461 00469 function &createInvoker(&$invoker) { 00470 return $this->_reporter->createInvoker($invoker); 00471 } 00472 00479 function getDumper() { 00480 return $this->_reporter->getDumper(); 00481 } 00482 00489 function paintGroupStart($test_name, $size) { 00490 $this->_reporter->paintGroupStart($test_name, $size); 00491 } 00492 00498 function paintGroupEnd($test_name) { 00499 $this->_reporter->paintGroupEnd($test_name); 00500 } 00501 00507 function paintCaseStart($test_name) { 00508 $this->_reporter->paintCaseStart($test_name); 00509 } 00510 00516 function paintCaseEnd($test_name) { 00517 $this->_reporter->paintCaseEnd($test_name); 00518 } 00519 00525 function paintMethodStart($test_name) { 00526 $this->_reporter->paintMethodStart($test_name); 00527 } 00528 00534 function paintMethodEnd($test_name) { 00535 $this->_reporter->paintMethodEnd($test_name); 00536 } 00537 00543 function paintPass($message) { 00544 $this->_reporter->paintPass($message); 00545 } 00546 00552 function paintFail($message) { 00553 $this->_reporter->paintFail($message); 00554 } 00555 00562 function paintError($message) { 00563 $this->_reporter->paintError($message); 00564 } 00565 00571 function paintException($exception) { 00572 $this->_reporter->paintException($exception); 00573 } 00574 00580 function paintSkip($message) { 00581 $this->_reporter->paintSkip($message); 00582 } 00583 00589 function paintMessage($message) { 00590 $this->_reporter->paintMessage($message); 00591 } 00592 00598 function paintFormattedMessage($message) { 00599 $this->_reporter->paintFormattedMessage($message); 00600 } 00601 00611 function paintSignal($type, &$payload) { 00612 $this->_reporter->paintSignal($type, $payload); 00613 } 00614 } 00615 00622 class MultipleReporter { 00623 var $_reporters = array(); 00624 00630 function attachReporter(&$reporter) { 00631 $this->_reporters[] = &$reporter; 00632 } 00633 00641 function makeDry($is_dry = true) { 00642 for ($i = 0; $i < count($this->_reporters); $i++) { 00643 $this->_reporters[$i]->makeDry($is_dry); 00644 } 00645 } 00646 00655 function getStatus() { 00656 for ($i = 0; $i < count($this->_reporters); $i++) { 00657 if (! $this->_reporters[$i]->getStatus()) { 00658 return false; 00659 } 00660 } 00661 return true; 00662 } 00663 00671 function shouldInvoke($test_case_name, $method) { 00672 for ($i = 0; $i < count($this->_reporters); $i++) { 00673 if (! $this->_reporters[$i]->shouldInvoke($test_case_name, $method)) { 00674 return false; 00675 } 00676 } 00677 return true; 00678 } 00679 00686 function &createInvoker(&$invoker) { 00687 for ($i = 0; $i < count($this->_reporters); $i++) { 00688 $invoker = &$this->_reporters[$i]->createInvoker($invoker); 00689 } 00690 return $invoker; 00691 } 00692 00699 function getDumper() { 00700 return new SimpleDumper(); 00701 } 00702 00709 function paintGroupStart($test_name, $size) { 00710 for ($i = 0; $i < count($this->_reporters); $i++) { 00711 $this->_reporters[$i]->paintGroupStart($test_name, $size); 00712 } 00713 } 00714 00720 function paintGroupEnd($test_name) { 00721 for ($i = 0; $i < count($this->_reporters); $i++) { 00722 $this->_reporters[$i]->paintGroupEnd($test_name); 00723 } 00724 } 00725 00731 function paintCaseStart($test_name) { 00732 for ($i = 0; $i < count($this->_reporters); $i++) { 00733 $this->_reporters[$i]->paintCaseStart($test_name); 00734 } 00735 } 00736 00742 function paintCaseEnd($test_name) { 00743 for ($i = 0; $i < count($this->_reporters); $i++) { 00744 $this->_reporters[$i]->paintCaseEnd($test_name); 00745 } 00746 } 00747 00753 function paintMethodStart($test_name) { 00754 for ($i = 0; $i < count($this->_reporters); $i++) { 00755 $this->_reporters[$i]->paintMethodStart($test_name); 00756 } 00757 } 00758 00764 function paintMethodEnd($test_name) { 00765 for ($i = 0; $i < count($this->_reporters); $i++) { 00766 $this->_reporters[$i]->paintMethodEnd($test_name); 00767 } 00768 } 00769 00775 function paintPass($message) { 00776 for ($i = 0; $i < count($this->_reporters); $i++) { 00777 $this->_reporters[$i]->paintPass($message); 00778 } 00779 } 00780 00786 function paintFail($message) { 00787 for ($i = 0; $i < count($this->_reporters); $i++) { 00788 $this->_reporters[$i]->paintFail($message); 00789 } 00790 } 00791 00798 function paintError($message) { 00799 for ($i = 0; $i < count($this->_reporters); $i++) { 00800 $this->_reporters[$i]->paintError($message); 00801 } 00802 } 00803 00809 function paintException($exception) { 00810 for ($i = 0; $i < count($this->_reporters); $i++) { 00811 $this->_reporters[$i]->paintException($exception); 00812 } 00813 } 00814 00820 function paintSkip($message) { 00821 for ($i = 0; $i < count($this->_reporters); $i++) { 00822 $this->_reporters[$i]->paintSkip($message); 00823 } 00824 } 00825 00831 function paintMessage($message) { 00832 for ($i = 0; $i < count($this->_reporters); $i++) { 00833 $this->_reporters[$i]->paintMessage($message); 00834 } 00835 } 00836 00842 function paintFormattedMessage($message) { 00843 for ($i = 0; $i < count($this->_reporters); $i++) { 00844 $this->_reporters[$i]->paintFormattedMessage($message); 00845 } 00846 } 00847 00857 function paintSignal($type, &$payload) { 00858 for ($i = 0; $i < count($this->_reporters); $i++) { 00859 $this->_reporters[$i]->paintSignal($type, $payload); 00860 } 00861 } 00862 } 00863 ?>