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. // 3 == debug output
  9. const VERBOSITY_NONE = 0;
  10. const VERBOSITY_STUDENT = 1;
  11. const VERBOSITY_STAFF = 2;
  12. const VERBOSITY_DEBUG = 3;
  13. private $verbosity = self::VERBOSITY_NONE;
  14. const STATUS_PASS = 'PASSED';
  15. const STATUS_SKIPPED = 'SKIPPED';
  16. const STATUS_INCOMPLETE = 'INCOMPLETE';
  17. const STATUS_FAILURE = 'FAILED';
  18. const STATUS_ERROR = 'ERROR';
  19. const STATUS_WARNING = 'WARNING';
  20. const STATUS_NOTE = 'NOTE';
  21. const STATUS_TEST = 'TEST';
  22. const STATUS_DEBUG = 'DEBUG';
  23. function __construct( $verbosity )
  24. {
  25. $this->verbosity = $verbosity;
  26. }
  27. public static function pluralise( $count, $oneText, $manyText )
  28. {
  29. return ( abs( $count ) !== 1 ) ? $manyText : $oneText;
  30. }
  31. public function setVerbosity( $newVerbosity )
  32. {
  33. $this->verbosity = $newVerbosity;
  34. }
  35. public function getVerbosity()
  36. {
  37. return $this->verbosity;
  38. }
  39. /**
  40. * $statusText is one of: PASSED, FAILED, ERROR, INCOMPLETE, SKIPPED, WARNING, NOTE, MISC, ...?
  41. * $reportText is a printf-style string (although we actually use vprintf because of the array)
  42. * $printfArguments is an array of arguments to $reportText
  43. */
  44. abstract public function report( $statusText, $reportText, $printfArguments = null );
  45. abstract public function hr();
  46. }
  47.  
  48. ?>