function setup()
 {
     $mockRequest = $this->getMock('LinkedDataApiRequest');
     $mockRequest->expects($this->any())->method('getParams')->will($this->returnValue(array('localAuthority.code' => '00BX', '_view' => 'detailed')));
     $mockRequest->expects($this->any())->method('getUnreservedParams')->will($this->returnValue(array('localAuthority.code' => '00BX')));
     $mockRequest->expects($this->any())->method('getBase')->will($this->returnValue("http://example.com"));
     $mockRequest->expects($this->any())->method('getPath')->will($this->returnValue("/doc/school/12345"));
     $mockRequest->expects($this->any())->method('getPathWithoutExtension')->will($this->returnValue("/doc/school/12345"));
     $mockRequest->expects($this->any())->method('getUri')->will($this->returnValue("http://example.com/doc/school/12345"));
     $ConfigGraph = new ConfigGraph(file_get_contents('../documents/config.ttl'), $mockRequest);
     $ConfigGraph->add_rdf(file_get_contents('../documents/test-data.ttl'));
     $ConfigGraph->init();
     $this->Graph = new LinkedDataApiGraph(file_get_contents('../documents/test-data.ttl'), $ConfigGraph);
     $this->Graph->_current_page_uri = "http://localhost/Things?_page=1";
 }
示例#2
0
 logDebug("Generating fresh response");
 $files = glob('api-config-files/*.ttl');
 /*
 	keep the config graph that matches the request, and keep a 'complete' configgraph to serve if none match
 */
 $CompleteConfigGraph = new ConfigGraph(null, $Request, $HttpRequestFactory);
 foreach ($files as $file) {
     logDebug("Iterating over files in /api-config: {$file}");
     if ($ConfigGraph = LinkedDataApiCache::hasCachedConfig($file)) {
         logDebug("Found Cached Config");
         $CompleteConfigGraph->add_graph($ConfigGraph);
         $ConfigGraph->setRequest($Request);
     } else {
         logDebug("Checking Config file: {$file}");
         $rdf = file_get_contents($file);
         $CompleteConfigGraph->add_rdf($rdf);
         $ConfigGraph = new ConfigGraph(null, $Request, $HttpRequestFactory);
         $ConfigGraph->add_rdf($rdf);
         $errors = $ConfigGraph->get_parser_errors();
         if (!empty($errors)) {
             foreach ($ConfigGraph->get_parser_errors() as $errorList) {
                 foreach ($errorList as $errorMsg) {
                     logDebug('Error parsing ' . $file . '  ' . $errorMsg);
                 }
             }
         }
         logDebug("Caching {$file}");
         LinkedDataApiCache::cacheConfig($file, $ConfigGraph);
     }
     $ConfigGraph->init();
     if ($selectedEndpointUri = $ConfigGraph->getEndpointUri()) {