1<?php
2
3namespace dokuwiki\plugin\structtasks\test;
4
5use dokuwiki\plugin\struct\meta\SchemaImporter;
6use dokuwiki\plugin\struct\test\StructTest;
7
8/**
9 * Override the loadSchemaJSON method so it looks in the correct
10 * directory
11 */
12class StructtasksTest extends StructTest {
13
14    /**
15     * Creates a schema from one of the available schema files
16     *
17     * @param string $schema
18     * @param string $json base name of the JSON file optional, defaults to $schema
19     * @param int $rev allows to create schemas back in time
20     * @param bool $lookup create as a lookup schema
21     */
22    protected function loadSchemaJSON($schema, $json = '', $rev = 0)
23    {
24        if (!$json) $json = $schema;
25        $file = __DIR__ . "/json/$json.struct.json";
26        if (!file_exists($file)) {
27            throw new \RuntimeException("$file does not exist");
28        }
29
30        $json = file_get_contents($file);
31        $importer = new SchemaImporter($schema, $json);
32
33        if (!$importer->build($rev)) {
34            throw new \RuntimeException("build of $schema from $file failed");
35        }
36    }
37}
38