testdox.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * base include file for SimpleTest
  4. * @package SimpleTest
  5. * @subpackage Extensions
  6. * @version $Id: testdox.php 1802 2008-09-08 10:43:58Z maetl_ $
  7. */
  8. /**
  9. * base include file for SimpleTest
  10. * @package SimpleTest
  11. * @subpackage Extensions
  12. * @version $Id: testdox.php 1802 2008-09-08 10:43:58Z maetl_ $
  13. */
  14. class TestDoxReporter extends SimpleReporter
  15. {
  16. var $_test_case_pattern = '/^TestOf(.*)$/';
  17. function TestDoxReporter($test_case_pattern = '/^TestOf(.*)$/') {
  18. parent::__construct();
  19. $this->_test_case_pattern = empty($test_case_pattern) ? '/^(.*)$/' : $test_case_pattern;
  20. }
  21. function paintCaseStart($test_name) {
  22. preg_match($this->_test_case_pattern, $test_name, $matches);
  23. if (!empty($matches[1])) {
  24. echo $matches[1] . "\n";
  25. } else {
  26. echo $test_name . "\n";
  27. }
  28. }
  29. function paintCaseEnd($test_name) {
  30. echo "\n";
  31. }
  32. function paintMethodStart($test_name) {
  33. if (!preg_match('/^test(.*)$/i', $test_name, $matches)) {
  34. return;
  35. }
  36. $test_name = $matches[1];
  37. $test_name = preg_replace('/([A-Z])([A-Z])/', '$1 $2', $test_name);
  38. echo '- ' . strtolower(preg_replace('/([a-zA-Z])([A-Z0-9])/', '$1 $2', $test_name));
  39. }
  40. function paintMethodEnd($test_name) {
  41. echo "\n";
  42. }
  43. function paintFail($message) {
  44. echo " [FAILED]";
  45. }
  46. }
  47. ?>