Пример #1
0
 public function testExtractPrefixesFromQueryNoPrefixes()
 {
     // assumption here is that fixture is of type
     $this->fixture = $this->queryFactory->createInstanceByQueryString('DELETE DATA { GRAPH <http://> { ?s ?p ?o } }');
     $queryParts = $this->fixture->getQueryParts();
     $this->assertFalse(isset($queryParts['prefixes']));
 }
Пример #2
0
 public function testExtractQuads()
 {
     // assumption here is that fixture is of type
     $this->fixture = $this->queryFactory->createInstanceByQueryString('PREFIX dc: <http://foo/bar/>
         INSERT DATA {
             Graph <http://saft/test/g1> { <http://saft/test/s1> dc:p1 <http://saft/test/o1>}
             Graph <http://saft/test/g1> {<http://saft/test/s2> <http://test/p2> <http://saft/test/o2>.}
             Graph <http://saft/test/g2> {
                 <http://saft/test/s3> dc:p3 "abc"^^<http://www.w3.org/2001/XMLSchema#string>
             }
         }');
     $queryParts = $this->fixture->getQueryParts();
     $this->assertEqualsArrays(array(array('s' => 'http://saft/test/s1', 'p' => 'http://foo/bar/p1', 'o' => 'http://saft/test/o1', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'uri', 'o_datatype' => null, 'o_lang' => null, 'g' => 'http://saft/test/g1', 'g_type' => 'uri'), array('s' => 'http://saft/test/s2', 'p' => 'http://test/p2', 'o' => 'http://saft/test/o2', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'uri', 'o_datatype' => null, 'o_lang' => null, 'g' => 'http://saft/test/g1', 'g_type' => 'uri'), array('s' => 'http://saft/test/s3', 'p' => 'http://foo/bar/p3', 'o' => 'abc', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'typed-literal', 'o_datatype' => 'http://www.w3.org/2001/XMLSchema#string', 'o_lang' => null, 'g' => 'http://saft/test/g2', 'g_type' => 'uri')), $queryParts['quad_pattern']);
 }
Пример #3
0
 public function testSaveResultCacheEntries()
 {
     $queryObject = $this->queryFactory->createInstanceByQueryString('SELECT ?s ?p ?o FROM <' . $this->testGraph->getUri() . '> WHERE { ?s ?p ?o }');
     $result = array(1, 2, 3);
     $this->fixture->saveResult($queryObject, $result);
     /**
      * check saved references between graph URIs (from query) and a array of query strings
      */
     $this->assertEquals(array($queryObject->getQuery() => $queryObject->getQuery()), $this->fixture->getCache()->load($this->testGraph->getUri()));
     /**
      * check saved references between triple pattern (from query) and a array of query strings
      */
     $this->assertEquals(array($queryObject->getQuery() => $queryObject->getQuery()), $this->fixture->getCache()->load($this->testGraph->getUri() . $this->separator . '*' . $this->separator . '*' . $this->separator . '*'));
     /**
      * check saved references between triple pattern (from query) and a array of query strings
      */
     $sep = $this->separator;
     $this->assertEquals(array('graph_uris' => array($this->testGraph->getUri() => $this->testGraph->getUri()), 'triple_pattern' => array($this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*' => $this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*'), 'result' => $result, 'query' => $queryObject->getQuery()), $this->fixture->getCache()->load($queryObject->getQuery()));
     /**
      * check, that upper query cache container was added to latestQueryCacheContainer during saveResult
      */
     $this->assertEquals(array(array('graph_uris' => array($this->testGraph->getUri() => $this->testGraph->getUri()), 'triple_pattern' => array($this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*' => $this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*'), 'result' => $result, 'query' => $queryObject->getQuery())), $this->fixture->getLatestQueryCacheContainer());
 }