testdox.php 1.3 KB

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