Reporter.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. class HTMLPurifier_SimpleTest_Reporter extends HTMLReporter
  3. {
  4. protected $ac;
  5. public function __construct($encoding, $ac) {
  6. $this->ac = $ac;
  7. parent::__construct($encoding);
  8. }
  9. public function paintHeader($test_name) {
  10. parent::paintHeader($test_name);
  11. ?>
  12. <form action="" method="get" id="select">
  13. <select name="f">
  14. <option value="" style="font-weight:bold;"<?php if(!$this->ac['file']) {echo ' selected';} ?>>All Tests</option>
  15. <?php foreach($GLOBALS['HTMLPurifierTest']['Files'] as $file) { ?>
  16. <option value="<?php echo $file ?>"<?php
  17. if ($this->ac['file'] == $file) echo ' selected';
  18. ?>><?php echo $file ?></option>
  19. <?php } ?>
  20. </select>
  21. <input type="checkbox" name="standalone" value="1" title="Standalone version?" <?php if($this->ac['standalone']) {echo 'checked="checked" ';} ?>/>
  22. <input type="submit" value="Go">
  23. </form>
  24. <?php
  25. flush();
  26. }
  27. public function paintFooter($test_name) {
  28. if (function_exists('xdebug_peak_memory_usage')) {
  29. $max_mem = number_format(xdebug_peak_memory_usage());
  30. echo "<div>Max memory usage: $max_mem bytes</div>";
  31. }
  32. parent::paintFooter($test_name);
  33. }
  34. protected function getCss() {
  35. $css = parent::getCss();
  36. $css .= '
  37. #select {position:absolute;top:0.2em;right:0.2em;}
  38. ';
  39. return $css;
  40. }
  41. function getTestList() {
  42. // hacky; depends on a specific implementation of paintPass, etc.
  43. $list = parent::getTestList();
  44. $testcase = $list[1];
  45. if (class_exists($testcase, false)) $file = str_replace('_', '/', $testcase) . '.php';
  46. else $file = $testcase;
  47. $list[1] = '<a href="index.php?file=' . $file . '">' . $testcase . '</a>';
  48. return $list;
  49. }
  50. }
  51. // vim: et sw=4 sts=4