File: ValidatorTestCase.php

package info (click to toggle)
php-htmlpurifier 4.4.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,888 kB
  • sloc: php: 27,456; xml: 1,767; makefile: 68; sh: 14
file content (44 lines) | stat: -rw-r--r-- 1,271 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

/**
 * Controller for validator test-cases.
 */
class HTMLPurifier_ConfigSchema_ValidatorTestCase extends UnitTestCase
{

    protected $_path, $_parser, $_builder;
    public $validator;

    public function __construct($path) {
        $this->_path = $path;
        $this->_parser  = new HTMLPurifier_StringHashParser();
        $this->_builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder();
        parent::__construct($path);
    }

    public function setup() {
        $this->validator = new HTMLPurifier_ConfigSchema_Validator();
    }

    function testValidator() {
        $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();
    }

}

// vim: et sw=4 sts=4