Ejemplo n.º 1
0
 function testResultParser()
 {
     echo "<b>ResultParser tests</b><br/>\n";
     foreach ($_SESSION['sparql_result'] as $name) {
         $_SESSION['test'] = $name . ' test';
         $parser = new SparqlResultParser();
         $qs = file_get_contents(SPARQL_TESTFILES . 'data/' . $name . '.xml', 'r');
         $res = file_get_contents(SPARQL_TESTFILES . 'result/' . $name . '.res', 'r');
         eval($res);
         $q = $parser->parse($qs);
         $this->assertTrue(SparqlTestHelper::resultCheck($q, $result));
     }
 }
Ejemplo n.º 2
0
 function testArqTestcases()
 {
     foreach ($_SESSION['sparql_arq_tests'] as $name) {
         $_SESSION['test'] = $name['query'] . " test";
         $parser = new SparqlParser();
         $graphset = ModelFactory::getDatasetMem('Dataset1');
         $def = $graphset->getDefaultGraph();
         $def->load(SPARQL_TESTFILES . 'data/' . $name['data']);
         $qs = file_get_contents(SPARQL_TESTFILES . 'query/' . $name['query'] . ".rq", 'r');
         $res = file_get_contents(SPARQL_TESTFILES . 'result/' . $name['result'] . ".res", 'r');
         eval($res);
         $q = $parser->parse($qs);
         $engine = SparqlEngine::factory();
         $t = $engine->queryModel($graphset, $q, false);
         if ($t instanceof MemModel) {
             $bOk = $t->equals($result);
         } else {
             $bOk = SparqlTestHelper::resultCheck($t, $result);
         }
         $this->assertTrue($bOk);
         if (!$bOk) {
             echo $name['query'] . "\n";
         }
     }
 }