Newer
Older
sqlmarker / Unit_testing / Reporter / TextReporter.php
  1. <?php
  2. require_once 'Reporter.php';
  3.  
  4. class TextReporter extends Reporter
  5. {
  6. public function report ( $status, $reportText, $printfArguments = null )
  7. {
  8. if ( ( $status === Reporter::STATUS_DEBUG ) && ( $this->getVerbosity() !== Reporter::VERBOSITY_DEBUG ) ) return;
  9. if ( $this->getVerbosity() > Reporter::VERBOSITY_NONE )
  10. {
  11. $statusText = '';
  12. switch ( $status )
  13. {
  14. case Reporter::STATUS_PASS:
  15. $statusText .= '+++ ';
  16. break;
  17. case Reporter::STATUS_SKIPPED:
  18. $statusText .= '### ';
  19. break;
  20. case Reporter::STATUS_INCOMPLETE:
  21. $statusText .= '%%% ';
  22. break;
  23. case Reporter::STATUS_FAILURE:
  24. $statusText .= '--- ';
  25. break;
  26. case Reporter::STATUS_ERROR:
  27. $statusText .= 'XXX ';
  28. break;
  29. case Reporter::STATUS_WARNING:
  30. $statusText .= '!!! ';
  31. break;
  32. case Reporter::STATUS_NOTE:
  33. case Reporter::STATUS_TEST:
  34. case Reporter::STATUS_DEBUG:
  35. break;
  36. default:
  37. $statusText .= '??? ';
  38. break;
  39. }
  40. if ( $this->getVerbosity() > Reporter::VERBOSITY_STUDENT ) $statusText .= $status . ': ';
  41. $output = vsprintf( $statusText . $reportText . "\n", $printfArguments );
  42. fwrite( STDOUT, $output );
  43. }
  44. }
  45. public function hr()
  46. {
  47. echo "------------------------------------------------------------\n";
  48. }
  49. }
  50.  
  51. ?>