testdox.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. class TestDoxReporter extends SimpleReporter
  3. {
  4. var $_test_case_pattern = '/^TestOf(.*)$/';
  5. function TestDoxReporter($test_case_pattern = '/^TestOf(.*)$/') {
  6. parent::SimpleScorer();
  7. $this->_test_case_pattern = empty($test_case_pattern) ? '/^(.*)$/' : $test_case_pattern;
  8. }
  9. function paintCaseStart($test_name) {
  10. preg_match($this->_test_case_pattern, $test_name, $matches);
  11. if (!empty($matches[1])) {
  12. echo $matches[1] . "\n";
  13. } else {
  14. echo $test_name . "\n";
  15. }
  16. }
  17. function paintCaseEnd() {
  18. echo "\n";
  19. }
  20. function paintMethodStart($test_name) {
  21. if (!preg_match('/^test(.*)$/i', $test_name, $matches)) {
  22. return;
  23. }
  24. $test_name = $matches[1];
  25. $test_name = preg_replace('/([A-Z])([A-Z])/', '$1 $2', $test_name);
  26. echo '- ' . strtolower(preg_replace('/([a-zA-Z])([A-Z0-9])/', '$1 $2', $test_name));
  27. }
  28. function paintMethodEnd() {
  29. echo "\n";
  30. }
  31. function paintFail() {
  32. echo " [FAILED]";
  33. }
  34. }