2008-03-23 01:06:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Controller for validator test-cases.
|
|
|
|
*/
|
|
|
|
class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-23 01:06:35 +00:00
|
|
|
protected $_path, $_parser, $_builder;
|
|
|
|
public $validator;
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-23 01:06:35 +00:00
|
|
|
public function __construct($path) {
|
|
|
|
$this->_path = $path;
|
|
|
|
$this->_parser = new HTMLPurifier_StringHashParser();
|
|
|
|
$this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
|
2008-04-21 15:24:18 +00:00
|
|
|
parent::__construct($path);
|
2008-03-23 01:06:35 +00:00
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-23 01:06:35 +00:00
|
|
|
public function setup() {
|
|
|
|
$this->validator = new HTMLPurifier_ConfigSchema_Validator();
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-04-21 15:24:18 +00:00
|
|
|
function testValidator() {
|
2008-03-23 01:06:35 +00:00
|
|
|
$hashes = $this->_parser->parseMultiFile($this->_path);
|
|
|
|
$interchange = new HTMLPurifier_ConfigSchema_Interchange();
|
|
|
|
$error = null;
|
|
|
|
foreach ($hashes as $hash) {
|
|
|
|
if (!isset($hash['ID'])) {
|
|
|
|
if (isset($hash['ERROR'])) {
|
|
|
|
$this->expectException(
|
|
|
|
new HTMLPurifier_ConfigSchema_Exception($hash['ERROR'])
|
|
|
|
);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->_builder->build($interchange, new HTMLPurifier_StringHash($hash));
|
|
|
|
}
|
|
|
|
$this->validator->validate($interchange);
|
|
|
|
$this->pass();
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-03-23 01:06:35 +00:00
|
|
|
}
|
2008-12-06 09:24:59 +00:00
|
|
|
|
|
|
|
// vim: et sw=4 sts=4
|