+
+resource('http://example.com/joe#me', 'foaf:Person');
+ $joe->add('foaf:name', 'Joe Bloggs');
+ $joe->addResource('foaf:homepage', 'http://example.com/joe/');
+
+ # Store it in a local graphstore
+ $store = new EasyRdf_GraphStore('http://localhost:8080/data/');
+ $store->replace($graph);
+
+ # Now make a query to the graphstore
+ $sparql = new EasyRdf_Sparql_Client('http://localhost:8080/sparql/');
+ $result = $sparql->query('SELECT * WHERE { ?p ?o}');
+ echo $result->dump();
+?>
+
+
+
diff --git a/core/vendor/easyrdf/easyrdf/test/EasyRdf/ExceptionTest.php b/core/vendor/easyrdf/easyrdf/test/EasyRdf/ExceptionTest.php
new file mode 100644
index 0000000..8be8603
--- /dev/null
+++ b/core/vendor/easyrdf/easyrdf/test/EasyRdf/ExceptionTest.php
@@ -0,0 +1,51 @@
+setExpectedException(
+ 'EasyRdf_Exception',
+ 'Test'
+ );
+ throw new EasyRdf_Exception('Test');
+ }
+}
diff --git a/core/vendor/easyrdf/easyrdf/test/EasyRdf/FormatTest.php b/core/vendor/easyrdf/easyrdf/test/EasyRdf/FormatTest.php
new file mode 100644
index 0000000..1bf6907
--- /dev/null
+++ b/core/vendor/easyrdf/easyrdf/test/EasyRdf/FormatTest.php
@@ -0,0 +1,635 @@
+format = EasyRdf_Format::register(
+ 'my',
+ 'My Format',
+ 'http://example.com/myformat',
+ array('my/mime' => 1.0, 'my/x-mime' => 0.9),
+ array('mext')
+ );
+ }
+
+ public function tearDown()
+ {
+ EasyRdf_Format::unregister('my');
+ }
+
+ public function testRegisterNameNull()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$name should be a string and cannot be null or empty'
+ );
+ EasyRdf_Format::register(null);
+ }
+
+ public function testRegisterNameEmpty()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$name should be a string and cannot be null or empty'
+ );
+ EasyRdf_Format::register('');
+ }
+
+ public function testRegisterNameNonString()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$name should be a string and cannot be null or empty'
+ );
+ EasyRdf_Format::register(array());
+ }
+
+ public function testGetFormats()
+ {
+ $formats = EasyRdf_Format::getFormats();
+ $this->assertInternalType('array', $formats);
+ $this->assertGreaterThan(0, count($formats));
+ foreach ($formats as $format) {
+ $this->assertClass('EasyRdf_Format', $format);
+ }
+ }
+
+ public function testGetHttpAcceptHeader()
+ {
+ $accept = EasyRdf_Format::getHttpAcceptHeader();
+ $this->assertContains('application/json', $accept);
+ $this->assertContains('application/rdf+xml;q=0.8', $accept);
+ }
+
+ public function testGetHttpAcceptHeaderWithExtra()
+ {
+ $accept = EasyRdf_Format::getHttpAcceptHeader(array('extra/header' => 0.5));
+ $this->assertContains('application/json', $accept);
+ $this->assertContains('extra/header;q=0.5', $accept);
+ }
+
+ public function testFormatExistsTrue()
+ {
+ $this->assertTrue(EasyRdf_Format::formatExists('my'));
+ }
+
+ public function testFormatExistsFalse()
+ {
+ $this->assertFalse(EasyRdf_Format::formatExists('testFormatExistsFalse'));
+ }
+
+ public function testUnRegister()
+ {
+ EasyRdf_Format::unregister('my');
+ $this->assertFalse(EasyRdf_Format::formatExists('my'));
+ }
+
+ public function testGetFormatByName()
+ {
+ $format = EasyRdf_Format::getFormat('my');
+ $this->assertNotNull($format);
+ $this->assertClass('EasyRdf_Format', $format);
+ $this->assertSame('my', $format->getName());
+ $this->assertSame('My Format', $format->getLabel());
+ $this->assertSame('http://example.com/myformat', $format->getUri());
+ }
+
+ public function testGetFormatByUri()
+ {
+ $format = EasyRdf_Format::getFormat('http://example.com/myformat');
+ $this->assertNotNull($format);
+ $this->assertClass('EasyRdf_Format', $format);
+ $this->assertSame('my', $format->getName());
+ $this->assertSame('My Format', $format->getLabel());
+ $this->assertSame('http://example.com/myformat', $format->getUri());
+ }
+
+ public function testGetFormatByMime()
+ {
+ $format = EasyRdf_Format::getFormat('my/mime');
+ $this->assertNotNull($format);
+ $this->assertClass('EasyRdf_Format', $format);
+ $this->assertSame('my', $format->getName());
+ $this->assertSame('My Format', $format->getLabel());
+ $this->assertSame('http://example.com/myformat', $format->getUri());
+ }
+
+ public function testGetFormatByMime2()
+ {
+ $format = EasyRdf_Format::getFormat('my/x-mime');
+ $this->assertNotNull($format);
+ $this->assertClass('EasyRdf_Format', $format);
+ $this->assertSame('my', $format->getName());
+ $this->assertSame('My Format', $format->getLabel());
+ $this->assertSame('http://example.com/myformat', $format->getUri());
+ }
+
+ public function testGetFormatByExtension()
+ {
+ $format = EasyRdf_Format::getFormat('mext');
+ $this->assertNotNull($format);
+ $this->assertClass('EasyRdf_Format', $format);
+ $this->assertSame('my', $format->getName());
+ $this->assertSame('My Format', $format->getLabel());
+ $this->assertSame('http://example.com/myformat', $format->getUri());
+ }
+
+ public function testGetFormatNull()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$query should be a string and cannot be null or empty'
+ );
+ EasyRdf_Format::getFormat(null);
+ }
+
+ public function testGetFormatEmpty()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$query should be a string and cannot be null or empty'
+ );
+ EasyRdf_Format::getFormat('');
+ }
+
+ public function testGetFormatNonString()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$query should be a string and cannot be null or empty'
+ );
+ EasyRdf_Format::getFormat(array());
+ }
+
+ public function testGetFormatUnknown()
+ {
+ $this->setExpectedException(
+ 'EasyRdf_Exception',
+ 'Format is not recognised: unknown'
+ );
+ $this->assertSame(null, EasyRdf_Format::getFormat('unknown'));
+ }
+
+ public function testGetNames()
+ {
+ $names = EasyRdf_Format::getNames();
+ $this->assertTrue(is_array($names));
+ $this->assertTrue(in_array('ntriples', $names));
+ }
+
+ public function testGetName()
+ {
+ $this->assertSame('my', $this->format->getName());
+ }
+
+ public function testGetLabel()
+ {
+ $this->assertSame('My Format', $this->format->getLabel());
+ }
+
+ public function testSetLabel()
+ {
+ $this->format->setLabel('testSetLabel');
+ $this->assertSame('testSetLabel', $this->format->getLabel());
+ }
+
+ public function testSetLabelNull()
+ {
+ $this->format->setLabel(null);
+ $this->assertSame(null, $this->format->getLabel());
+ }
+
+ public function testSetLabelEmpty()
+ {
+ $this->format->setLabel('');
+ $this->assertSame(null, $this->format->getLabel());
+ }
+
+ public function testSetLabelNonString()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$label should be a string'
+ );
+ $this->format->setLabel($this);
+ }
+
+ public function testSetUri()
+ {
+ $this->format->setUri('testSetUri');
+ $this->assertSame('testSetUri', $this->format->getUri());
+ }
+
+ public function testSetUriNull()
+ {
+ $this->format->setUri(null);
+ $this->assertSame(null, $this->format->getUri());
+ }
+
+ public function testSetUriEmpty()
+ {
+ $this->format->setUri('');
+ $this->assertSame(null, $this->format->getUri());
+ }
+
+ public function testSetUriNonString()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$uri should be a string'
+ );
+ $this->format->setUri($this);
+ }
+
+ public function testGetUri()
+ {
+ $this->assertSame(
+ 'http://example.com/myformat',
+ $this->format->getUri()
+ );
+ }
+
+ public function testGetDefaultMimeType()
+ {
+ $this->assertSame(
+ 'my/mime',
+ $this->format->getDefaultMimeType()
+ );
+ }
+
+ public function testGetMimeTypes()
+ {
+ $this->assertSame(
+ array('my/mime' => 1.0, 'my/x-mime' => 0.9),
+ $this->format->getMimeTypes()
+ );
+ }
+
+ public function testSetMimeType()
+ {
+ $this->format->setMimeTypes('testSetMimeType');
+ $this->assertSame(
+ array('testSetMimeType'),
+ $this->format->getMimeTypes()
+ );
+ }
+
+ public function testSetMimeTypes()
+ {
+ $this->format->setMimeTypes(
+ array('testSetMimeTypes1', 'testSetMimeTypes2')
+ );
+ $this->assertSame(
+ array('testSetMimeTypes1', 'testSetMimeTypes2'),
+ $this->format->getMimeTypes()
+ );
+ }
+
+ public function testSetMimeTypeNull()
+ {
+ $this->format->setMimeTypes(null);
+ $this->assertSame(array(), $this->format->getMimeTypes());
+ }
+
+ public function testGetDefaultExtension()
+ {
+ $this->assertSame(
+ 'mext',
+ $this->format->getDefaultExtension()
+ );
+ }
+
+ public function testGetExtensions()
+ {
+ $this->assertSame(
+ array('mext'),
+ $this->format->getExtensions()
+ );
+ }
+
+ public function testSetExtension()
+ {
+ $this->format->setExtensions('testSetExtension');
+ $this->assertSame(
+ array('testSetExtension'),
+ $this->format->getExtensions()
+ );
+ }
+
+ public function testSetExtensions()
+ {
+ $this->format->setExtensions(
+ array('ext1', 'ext2')
+ );
+ $this->assertSame(
+ array('ext1', 'ext2'),
+ $this->format->getExtensions()
+ );
+ }
+
+ public function testSetExtensionsNull()
+ {
+ $this->format->setExtensions(null);
+ $this->assertSame(array(), $this->format->getExtensions());
+ }
+
+ public function testToString()
+ {
+ $this->assertStringEquals('my', $this->format);
+ }
+
+ public function testSetParserClass()
+ {
+ $this->format->setParserClass('MockParserClass');
+ $this->assertSame(
+ 'MockParserClass',
+ $this->format->getParserClass()
+ );
+ }
+
+ public function testSetParserClassNull()
+ {
+ $this->format->setParserClass(null);
+ $this->assertSame(null, $this->format->getParserClass());
+ }
+
+ public function testSetParserClassEmpty()
+ {
+ $this->format->setParserClass('');
+ $this->assertSame(null, $this->format->getParserClass());
+ }
+
+ public function testSetParserClassNonString()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$class should be a string'
+ );
+ $this->format->setParserClass($this);
+ }
+
+ public function testRegisterParser()
+ {
+ EasyRdf_Format::registerParser('my', 'MockParserClass');
+ $this->assertSame(
+ 'MockParserClass',
+ $this->format->getParserClass()
+ );
+ }
+
+ public function testRegisterParserForUnknownFormat()
+ {
+ EasyRdf_Format::registerParser('testRegisterParser', 'MockParserClass');
+ $format = EasyRdf_Format::getFormat('testRegisterParser');
+ $this->assertNotNull($format);
+ $this->assertSame('MockParserClass', $format->getParserClass());
+ }
+
+ public function testNewParser()
+ {
+ $this->format->setParserClass('MockParserClass');
+ $parser = $this->format->newParser();
+ $this->assertInternalType('object', $parser);
+ $this->assertClass('MockParserClass', $parser);
+ }
+
+ public function testNewParserNull()
+ {
+ $this->setExpectedException(
+ 'EasyRdf_Exception',
+ 'No parser class available for format: my'
+ );
+ $this->format->setParserClass(null);
+ $parser = $this->format->newParser();
+ }
+
+ public function testSetSerialiserClass()
+ {
+ $this->format->setSerialiserClass('MockSerialiserClass');
+ $this->assertSame(
+ 'MockSerialiserClass',
+ $this->format->getSerialiserClass()
+ );
+ }
+
+ public function testSetSerialiserClassNull()
+ {
+ $this->format->setSerialiserClass(null);
+ $this->assertSame(null, $this->format->getSerialiserClass());
+ }
+
+ public function testSetSerialiserClassEmpty()
+ {
+ $this->format->setSerialiserClass('');
+ $this->assertSame(null, $this->format->getSerialiserClass());
+ }
+
+ public function testSetSerialiserClassNonString()
+ {
+ $this->setExpectedException(
+ 'InvalidArgumentException',
+ '$class should be a string'
+ );
+ $this->format->setSerialiserClass($this);
+ }
+
+ public function testNewSerialiser()
+ {
+ $this->format->setSerialiserClass('MockSerialiserClass');
+ $serialiser = $this->format->newSerialiser();
+ $this->assertInternalType('object', $serialiser);
+ $this->assertClass('MockSerialiserClass', $serialiser);
+ }
+
+ public function testNewSerialiserNull()
+ {
+ $this->setExpectedException(
+ 'EasyRdf_Exception',
+ 'No serialiser class available for format: my'
+ );
+ $this->format->setSerialiserClass(null);
+ $serialiser = $this->format->newSerialiser();
+ }
+
+ public function testRegisterSerialiser()
+ {
+ EasyRdf_Format::registerSerialiser('my', 'MockSerialiserClass');
+ $this->assertSame(
+ 'MockSerialiserClass',
+ $this->format->getSerialiserClass()
+ );
+ }
+
+ public function testRegisterSerialiserForUnknownFormat()
+ {
+ EasyRdf_Format::registerSerialiser(
+ 'testRegisterSerialiser',
+ 'MockSerialiserClass'
+ );
+ $format = EasyRdf_Format::getFormat('testRegisterSerialiser');
+ $this->assertNotNull($format);
+ $this->assertSame(
+ 'MockSerialiserClass',
+ $format->getSerialiserClass()
+ );
+ }
+
+ public function testGuessFormatPhp()
+ {
+ $data = array('http://www.example.com' => array());
+ $this->assertStringEquals('php', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatRdfXml()
+ {
+ $data = readFixture('foaf.rdf');
+ $this->assertStringEquals('rdfxml', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatJson()
+ {
+ $data = readFixture('foaf.json');
+ $this->assertStringEquals('json', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatTurtle()
+ {
+ $data = readFixture('foaf.ttl');
+ $this->assertStringEquals('turtle', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatTurtleWithComments()
+ {
+ $data = readFixture('webid.ttl');
+ $this->assertStringEquals('turtle', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatNtriples()
+ {
+ $data = readFixture('foaf.nt');
+ $this->assertStringEquals('ntriples', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatNtriplesWithComments()
+ {
+ $format = EasyRdf_Format::guessFormat(
+ "# This is a comment before the first triple\n".
+ " .\n"
+ );
+ $this->assertStringEquals('ntriples', $format);
+ }
+
+ public function testGuessFormatSparqlXml()
+ {
+ $data = readFixture('sparql_select_all.xml');
+ $this->assertStringEquals('sparql-xml', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatRdfa()
+ {
+ $data = readFixture('foaf.html');
+ $this->assertStringEquals('rdfa', EasyRdf_Format::guessFormat($data));
+ }
+
+ public function testGuessFormatHtml()
+ {
+ # We don't support any other microformats embedded in HTML
+ $format = EasyRdf_Format::guessFormat(
+ 'Hello
Hello World
'
+ );
+ $this->assertStringEquals('rdfa', $format);
+ }
+
+ public function testGuessFormatXml()
+ {
+ # We support several different XML formats, don't know which one this is...
+ $format = EasyRdf_Format::guessFormat(
+ ''
+ );
+ $this->assertSame(null, $format);
+ }
+
+ public function testGuessFormatByFilenameTtl()
+ {
+ $format = EasyRdf_Format::guessFormat(
+ '# This is a comment',
+ 'http://example.com/filename.ttl'
+ );
+ $this->assertStringEquals('turtle', $format);
+ }
+
+ public function testGuessFormatByFilenameRdf()
+ {
+ $format = EasyRdf_Format::guessFormat(
+ '
+