resetDB(); } /** * Creates a schema from one of the available schema files * * @param string $schema * @param string $json base name of the JSON file optional, defaults to $schema */ protected function loadSchemaJSON($schema, $json='') { if(!$json) $json = $schema; $file = __DIR__ . "/json/$json.struct.json"; if(!file_exists($file)) { throw new \RuntimeException("$file does not exist"); } $importer = new SchemaImporter($schema, file_get_contents($file)); if(!$importer->build()) { throw new \RuntimeException("build of $schema from $file failed"); } } /** * This waits until a new second has passed * * The very first call will return immeadiately, proceeding calls will return * only after at least 1 second after the last call has passed * * @return int new timestamp */ protected function waitForTick() { static $last = 0; while ( $last === $now = time() ) { usleep(100000); //recheck in a 10th of a second } $last = $now; return $now; } /** * Saves struct data for given page and schema * * @param string $page * @param string $schema * @param array $data */ protected function saveData($page, $schema, $data) { saveWikiText($page, "test for $page", "saved for testing"); $schemaData = new SchemaData($schema, $page, time()); $schemaData->saveData($data); } }