ValidatorTestCase.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. $this->_path = $path;
  11. $this->_parser = new HTMLPurifier_StringHashParser();
  12. $this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
  13. parent::__construct($path);
  14. }
  15. public function setup() {
  16. $this->validator = new HTMLPurifier_ConfigSchema_Validator();
  17. }
  18. function testValidator() {
  19. $hashes = $this->_parser->parseMultiFile($this->_path);
  20. $interchange = new HTMLPurifier_ConfigSchema_Interchange();
  21. $error = null;
  22. foreach ($hashes as $hash) {
  23. if (!isset($hash['ID'])) {
  24. if (isset($hash['ERROR'])) {
  25. $this->expectException(
  26. new HTMLPurifier_ConfigSchema_Exception($hash['ERROR'])
  27. );
  28. }
  29. continue;
  30. }
  31. $this->_builder->build($interchange, new HTMLPurifier_StringHash($hash));
  32. }
  33. $this->validator->validate($interchange);
  34. $this->pass();
  35. }
  36. }
  37. // vim: et sw=4 sts=4