summaryrefslogtreecommitdiff
path: root/test/HTML5/DataHarness.php
blob: 844b1fc21b094c8ff8c7d89dbe7490402b1be1ae (plain)
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
45
46
47
48
<?php

/**
 * Modified test-case supertype for running tests that are not
 * test method based, but based off of test data that resides in
 * files.
 */
SimpleTest::ignore('HTML5_DataHarness');
abstract class HTML5_DataHarness extends UnitTestCase
{
    /**
     * Filled in by HTML5_TestData::generateTestCases()
     */
    protected $filename;
    private $tests;
    /**
     * Invoked by the runner, it is the function responsible for executing
     * the test and delivering results.
     * @param $test Some easily usable representation of the test
     */
    abstract public function invoke($test);
    /**
     * Returns a list of tests that can be executed. The list members will
     * be passed to invoke(). Return an iterator if you don't want to load
     * all test into memory
     */
    abstract public function getDataTests();
    /**
     * Returns a description of the test
     */
    abstract public function getDescription($test);
    public function getTests() {
        $this->tests = $this->getDataTests();
        // 1-indexed, to be consistent with Python
        $ret = array();
        for ($i = 1; $i <= count($this->tests); $i++) {
            $ret[] = "test_$i";
        }
        return $ret;
    }
    /**
     * Emulates our test functions
     */
    public function __call($name, $args) {
        list($test, $i) = explode("_", $name);
        $this->invoke($this->tests[$i-1]);
    }
}