public function testSerializeResourceToString() { $this->markTestNeedsDatabase(); $this->authenticateDbUser(); $r = 'http://localhost/OntoWiki/Config/'; $result = $this->_object->serializeResourceToString($r, $r); $this->assertTrue(is_string($result)); }
public function testCorrectness() { $triples = array('http://example.com/s' => array('http://example.com/p' => array(array('type' => 'uri', 'value' => 'http://example.com/o')))); $json = json_encode($triples); $result = $this->_object->parseFromDataString($json); //decode $this->assertEquals($triples, $result); }
public function testSerializeResourceToStringWithN3() { $this->markTestNeedsDatabase(); $this->authenticateDbUser(); $g = 'http://localhost/OntoWiki/Config/'; $this->_object->initializeWithFormat('ttl'); $result1 = $this->_object->serializeResourceToString($g, $g); require_once 'Erfurt/Syntax/RdfSerializer/Adapter/Turtle.php'; $adapter = new Erfurt_Syntax_RdfSerializer_Adapter_Turtle(); $result2 = $adapter->serializeResourceToString($g, $g); $this->assertEquals($result1, $result2); }
public function testParseRecursiveEntity() { $xml = '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE rdf:RDF [ <!ENTITY location "http://www.w3.org/2002/07/owl"> <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"> <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#"> <!ENTITY dc "http://purl.org/dc/elements/1.1/"> <!ENTITY grddl "http://www.w3.org/2003/g/data-view#"> <!ENTITY owl "&location;#" > ]> <rdf:RDF xml:base="&location;" xmlns:conferences="&location;" xmlns:owl="&owl;" xmlns:rdf="&rdf;"> <owl:Class rdf:about="#test" /> </rdf:RDF>'; try { $result = $this->_object->parseFromDataString($xml); $this->assertEquals('http://www.w3.org/2002/07/owl#Class', $result['http://www.w3.org/2002/07/owl#test'][EF_RDF_TYPE][0]['value']); } catch (Erfurt_Syntax_RdfParserException $e) { $this->fail($e->getMessage()); } }
/** * @medium **/ public function testParseWithUrlAndRdfXml302After303GithubOntoWikiIssue101() { $this->_object->initializeWithFormat('rdfxml'); $adapter = new Zend_Http_Client_Adapter_Test(); $this->_object->setHttpClientAdapter($adapter); $adapter->setResponse(new Zend_Http_Response(302, array('Content-Type' => 'text/html; charset=iso-8859-1', 'Location' => 'http://motools.sourceforge.net/mo/'))); $adapter->addResponse(new Zend_Http_Response(303, array('Content-Type' => 'text/html; charset=iso-8859-1', 'Location' => 'http://motools.sourceforge.net/doc/musicontology.rdfs'))); $adapter->addResponse(new Zend_Http_Response(200, array('Content-Type' => 'application/rdf+xml'), file_get_contents($this->_resourcesDirectory . 'valid/musicontology.rdfs'))); $result = $this->_object->parse('http://purl.org/ontology/mo/', Erfurt_Syntax_RdfParser::LOCATOR_URL); $this->assertInternalType('array', $result); }