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.

48 lines
1.3KB

  1. <?php
  2. /**
  3. * Controller for validator test-cases.
  4. */
  5. class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
  6. {
  7. protected $_path, $_parser, $_builder;
  8. public $validator;
  9. public function __construct($path)
  10. {
  11. $this->_path = $path;
  12. $this->_parser = new HTMLPurifier_StringHashParser();
  13. $this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
  14. parent::__construct($path);
  15. }
  16. public function setup()
  17. {
  18. $this->validator = new HTMLPurifier_ConfigSchema_Validator();
  19. }
  20. public function testValidator()
  21. {
  22. $hashes = $this->_parser->parseMultiFile($this->_path);
  23. $interchange = new HTMLPurifier_ConfigSchema_Interchange();
  24. $error = null;
  25. foreach ($hashes as $hash) {
  26. if (!isset($hash['ID'])) {
  27. if (isset($hash['ERROR'])) {
  28. $this->expectException(
  29. new HTMLPurifier_ConfigSchema_Exception($hash['ERROR'])
  30. );
  31. }
  32. continue;
  33. }
  34. $this->_builder->build($interchange, new HTMLPurifier_StringHash($hash));
  35. }
  36. $this->validator->validate($interchange);
  37. $this->pass();
  38. }
  39. }
  40. // vim: et sw=4 sts=4