Newer
Older
sqlmarker / Unit_testing / Reporter.php
  1. <?php
  2.  
  3. abstract class Reporter
  4. {
  5. // 0 == no output
  6. // 1 == brief output (students?)
  7. // 2 == verbose output (marking)
  8. private $verbosity = 0;
  9. const STATUS_PASS = 'PASSED';
  10. const STATUS_SKIPPED = 'SKIPPED';
  11. const STATUS_INCOMPLETE = 'INCOMPLETE';
  12. const STATUS_FAILURE = 'FAILED';
  13. const STATUS_ERROR = 'ERROR';
  14. const STATUS_WARNING = 'WARNING';
  15. const STATUS_NOTE = 'NOTE';
  16. const STATUS_TEST = 'TEST';
  17. function __construct( $verbosity )
  18. {
  19. $this->verbosity = $verbosity;
  20. }
  21. public static function pluralise( $count, $oneText, $manyText )
  22. {
  23. return ( abs( $count ) !== 1 ) ? $manyText : $oneText;
  24. }
  25. public function setVerbosity( $newVerbosity )
  26. {
  27. $this->verbosity = $newVerbosity;
  28. }
  29. public function getVerbosity()
  30. {
  31. return $this->verbosity;
  32. }
  33. /**
  34. * $reportText is one of: PASSED, FAILED, ERROR, INCOMPLETE, SKIPPED, WARNING, NOTE, MISC, ...?
  35. * $reportText is a printf-style string (although we actually use vprintf because of the array)
  36. * $printfArguments is an array of arguments to $reportText
  37. */
  38. public function report( $statusText, $reportText, $printfArguments = null )
  39. {
  40. if ( $this->verbosity ) vprintf( $statusText . $reportText . "\n", $printfArguments );
  41. }
  42. abstract public function hr();
  43. }
  44.  
  45. ?>