You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VarParserHarness.php 857B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. class HTMLPurifier_VarParserHarness extends UnitTestCase
  3. {
  4. protected $parser;
  5. public function setup()
  6. {
  7. $class = substr(get_class($this), 0, -4);
  8. $this->parser = new $class();
  9. }
  10. public function assertValid($var, $type, $ret = null)
  11. {
  12. $ret = ($ret === null) ? $var : $ret;
  13. $this->assertIdentical($this->parser->parse($var, $type), $ret);
  14. }
  15. public function assertInvalid($var, $type, $msg = null)
  16. {
  17. $caught = false;
  18. try {
  19. $this->parser->parse($var, $type);
  20. } catch (HTMLPurifier_VarParserException $e) {
  21. $caught = true;
  22. if ($msg !== null) $this->assertIdentical($e->getMessage(), $msg);
  23. }
  24. if (!$caught) {
  25. $this->fail('Did not catch expected error');
  26. }
  27. }
  28. }
  29. // vim: et sw=4 sts=4