Compare commits

..

4 Commits

5 changed files with 210 additions and 115 deletions

View File

@@ -19,7 +19,8 @@ class CloudObject {
private $coid; private $coid;
private $node; private $node;
private $reader; private $reader = null;
private $retriever = null;
public function __construct(IRI $coid, Node $node) { public function __construct(IRI $coid, Node $node) {
Assert::eq((string)$coid, $node->getId(), "COID and Node ID must match."); Assert::eq((string)$coid, $node->getId(), "COID and Node ID must match.");
@@ -32,17 +33,29 @@ class CloudObject {
* Specify a custom NodeReader to use for this CloudObject. * Specify a custom NodeReader to use for this CloudObject.
* If not set, a default NodeReader will be used. * If not set, a default NodeReader will be used.
*/ */
public function setReader(NodeReader $reader) { public function setReader(NodeReader $reader) : self {
$this->reader = $reader; $this->reader = $reader;
return $this;
} }
private function getReader() { private function getReader() : NodeReader {
if (!$this->reader) { if (!$this->reader) {
$this->reader = new NodeReader; $this->reader = new NodeReader;
} }
return $this->reader; return $this->reader;
} }
/**
* Specify an ObjectRetriever to use for retrieval
* of related objects.
*/
public function setObjectRetriever(ObjectRetriever $retriever) : self {
$this->retriever = $retriever;
return $this;
}
/** /**
* Get the COID of this object. * Get the COID of this object.
*/ */
@@ -51,7 +64,7 @@ class CloudObject {
} }
/** /**
* Get the raw object node. * Get the object node encapsulated in this CloudObject.
*/ */
public function getObjectNode() : Node { public function getObjectNode() : Node {
return $this->node; return $this->node;
@@ -105,4 +118,19 @@ class CloudObject {
return $this->getReader()->getFirstValueNode($this->node, $property, $default); return $this->getReader()->getFirstValueNode($this->node, $property, $default);
} }
/**
* Get the value of a property and, if it's a COID, retrieve the corresponding CloudObject.
*/
public function getCloudObject($property) : ?CloudObject {
Assert::notNull($this->retriever, "No ObjectRetriever set for CloudObject. Cannot retrieve related object.");
$coid = $this->getReader()->getFirstValueIRI($this->node, $property);
if (!($coid instanceof IRI)) {
return null;
}
return $this->retriever->getCloudObject($coid);
}
} }

View File

@@ -29,6 +29,7 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
private $options; private $options;
private $cache; private $cache;
private $objects; private $objects;
private $defaultReader;
const CO_API_URL = 'https://api.cloudobjects.net/'; const CO_API_URL = 'https://api.cloudobjects.net/';
@@ -107,6 +108,22 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
$this->client = new Client($options); $this->client = new Client($options);
} }
/**
* Set a default reader for CloudObject instances.
*/
public function setDefaultReader(NodeReader $reader) : self {
$this->defaultReader = $reader;
return $this;
}
/**
* Get the default reader for CloudObject instances.
*/
public function getDefaultReader() : NodeReader {
return $this->defaultReader;
}
public function logInfoWithTime($message, $ts) { public function logInfoWithTime($message, $ts) {
if (isset($this->logger)) if (isset($this->logger))
$this->logger->info($message, [ 'elapsed_ms' => round((microtime(true) - $ts) * 1000) ]); $this->logger->info($message, [ 'elapsed_ms' => round((microtime(true) - $ts) * 1000) ]);
@@ -179,7 +196,15 @@ class ObjectRetriever implements CustomCacheAndLogInterface {
return null; return null;
} }
return new CloudObject($coid, $node); $object = (new CloudObject($coid, $node))
->setObjectRetriever($this);
if ($this->defaultReader) {
// Initialize CloudObject with default reader if it is set
$object->setReader($this->defaultReader);
}
return $object;
} }
/** /**

View File

@@ -7,150 +7,180 @@
namespace CloudObjects\SDK; namespace CloudObjects\SDK;
use ML\IRI\IRI; use ML\IRI\IRI;
use ML\JsonLD\Node;
use GuzzleHttp\Client, GuzzleHttp\Handler\MockHandler, use GuzzleHttp\Client, GuzzleHttp\Handler\MockHandler,
GuzzleHttp\HandlerStack, GuzzleHttp\Psr7\Response; GuzzleHttp\HandlerStack, GuzzleHttp\Psr7\Response;
class NodeReaderMockTest extends \PHPUnit\Framework\TestCase { class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
private $retriever; private $retriever;
private $reader; private $reader;
private function setMockResponse(Response $response) { private function setMockResponse(Response $response) {
$mock = new MockHandler([$response]); $mock = new MockHandler([$response]);
$handler = HandlerStack::create($mock); $handler = HandlerStack::create($mock);
$this->retriever->setClient(new Client(['handler' => $handler])); $this->retriever->setClient(new Client(['handler' => $handler]));
} }
private function useRootResourceMock() { private function useRootResourceMock() {
$this->setMockResponse(new Response(200, $this->setMockResponse(new Response(200,
['Content-Type' => 'application/ld+json'], ['Content-Type' => 'application/ld+json'],
'{"@context":{"co":"coid:\/\/cloudobjects.io\/","rdf":"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#","agws":"coid:\/\/aauid.net\/","rdfs":"http:\/\/www.w3.org\/2000\/01\/rdf-schema#"},"@id":"coid:\/\/cloudobjects.io","@type":["agws:Service","co:Namespace"],"co:isAtRevision":"6-fbea0c90b2c5e5300e4039ed99be9b2d","co:isVisibleTo":{"@id":"co:Public"},"co:recommendsPrefix":"co","co:wasUpdatedAt":{"@type":"http:\/\/www.w3.org\/2001\/XMLSchema#dateTime","@value":"2017-01-16T17:29:22+00:00"},"rdfs:comment":"The CloudObjects namespace defines the essential objects.","rdfs:label":"CloudObjects"}')); '{"@context":{"co":"coid:\/\/cloudobjects.io\/","rdf":"http:\/\/www.w3.org\/1999\/02\/22-rdf-syntax-ns#","agws":"coid:\/\/aauid.net\/","rdfs":"http:\/\/www.w3.org\/2000\/01\/rdf-schema#"},"@id":"coid:\/\/cloudobjects.io","@type":["agws:Service","co:Namespace"],"co:isAtRevision":"6-fbea0c90b2c5e5300e4039ed99be9b2d","co:isVisibleTo":{"@id":"co:Public"},"co:recommendsPrefix":"co","co:wasUpdatedAt":{"@type":"http:\/\/www.w3.org\/2001\/XMLSchema#dateTime","@value":"2017-01-16T17:29:22+00:00"},"rdfs:comment":"The CloudObjects namespace defines the essential objects.","rdfs:label":"CloudObjects"}'
} ));
}
protected function setUp(): void { protected function setUp(): void {
$this->retriever = new ObjectRetriever; $this->retriever = new ObjectRetriever;
$this->reader = new NodeReader([ $this->reader = new NodeReader([
'prefixes' => [ 'prefixes' => [
'co' => 'coid://cloudobjects.io/', 'co' => 'coid://cloudobjects.io/',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#' 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#'
] ]
]); ]);
} $this->retriever->setDefaultReader($this->reader);
}
public function testHasType1() { public function testHasType1() {
$coid = new IRI('coid://cloudobjects.io'); $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock(); $this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid); $object = $this->retriever->getObjectNode($coid);
$this->assertTrue($this->reader->hasType($object, 'coid://cloudobjects.io/Namespace')); $this->assertTrue($this->reader->hasType($object, 'coid://cloudobjects.io/Namespace'));
$this->assertTrue($this->reader->hasType($object, 'co:Namespace')); $this->assertTrue($this->reader->hasType($object, 'co:Namespace'));
$this->assertFalse($this->reader->hasType($object, 'coid://cloudobjects.io/MemberRole')); $this->assertFalse($this->reader->hasType($object, 'coid://cloudobjects.io/MemberRole'));
$this->assertFalse($this->reader->hasType($object, 'co:MemberRole')); $this->assertFalse($this->reader->hasType($object, 'co:MemberRole'));
} }
public function testHasPropertyValue1() { public function testHasPropertyValue1() {
$coid = new IRI('coid://cloudobjects.io'); $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock(); $this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid); $object = $this->retriever->getObjectNode($coid);
$this->assertTrue($this->reader->hasPropertyValue($object, 'http://www.w3.org/2000/01/rdf-schema#label', 'CloudObjects')); $this->assertTrue($this->reader->hasPropertyValue($object, 'http://www.w3.org/2000/01/rdf-schema#label', 'CloudObjects'));
$this->assertTrue($this->reader->hasPropertyValue($object, 'rdfs:label', 'CloudObjects')); $this->assertTrue($this->reader->hasPropertyValue($object, 'rdfs:label', 'CloudObjects'));
} }
public function testGetFirstValueString1() { public function testGetFirstValueString1() {
$coid = new IRI('coid://cloudobjects.io'); $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock(); $this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid); $object = $this->retriever->getObjectNode($coid);
$this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'http://www.w3.org/2000/01/rdf-schema#label')); $this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
$this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'rdfs:label')); $this->assertEquals('CloudObjects', $this->reader->getFirstValueString($object, 'rdfs:label'));
$this->assertNull($this->reader->getFirstValueString($object, 'coid://cloudobjects.io/makesTriplesVisibleTo')); $this->assertNull($this->reader->getFirstValueString($object, 'coid://cloudobjects.io/makesTriplesVisibleTo'));
$this->assertNull($this->reader->getFirstValueString($object, 'co:makesTriplesVisibleTo')); $this->assertNull($this->reader->getFirstValueString($object, 'co:makesTriplesVisibleTo'));
$this->assertEquals('theDefaultValue', $this->reader->getFirstValueString($object, 'coid://cloudobjects.io/makesTriplesVisibleTo', 'theDefaultValue')); $this->assertEquals('theDefaultValue', $this->reader->getFirstValueString($object, 'coid://cloudobjects.io/makesTriplesVisibleTo', 'theDefaultValue'));
$this->assertEquals('theDefaultValue', $this->reader->getFirstValueString($object, 'co:makesTriplesVisibleTo', 'theDefaultValue')); $this->assertEquals('theDefaultValue', $this->reader->getFirstValueString($object, 'co:makesTriplesVisibleTo', 'theDefaultValue'));
}
public function testGetFirstValueIRI1() { $object = $this->retriever->getCloudObject($coid);
$coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getFirstValueIRI($object, 'coid://cloudobjects.io/isVisibleTo')); $this->assertEquals('CloudObjects', $object->getString('http://www.w3.org/2000/01/rdf-schema#label'));
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getFirstValueIRI($object, 'co:isVisibleTo')); $this->assertEquals('CloudObjects', $object->getString('rdfs:label'));
$this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getFirstValueIRI($object, 'coid://cloudobjects.io/isVisibleTo')); $this->assertNull($object->getString('coid://cloudobjects.io/makesTriplesVisibleTo'));
$this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getFirstValueIRI($object, 'co:isVisibleTo')); $this->assertNull($object->getString('co:makesTriplesVisibleTo'));
}
public function testGetFirstValueNode1() { $this->assertEquals('theDefaultValue', $object->getString('coid://cloudobjects.io/makesTriplesVisibleTo', 'theDefaultValue'));
$coid = new IRI('coid://cloudobjects.io'); $this->assertEquals('theDefaultValue', $object->getString('co:makesTriplesVisibleTo', 'theDefaultValue'));
$this->useRootResourceMock(); }
$object = $this->retriever->getObjectNode($coid);
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getFirstValueNode($object, 'coid://cloudobjects.io/isVisibleTo')); public function testGetFirstValueIRI1() {
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getFirstValueNode($object, 'co:isVisibleTo')); $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getFirstValueNode($object, 'coid://cloudobjects.io/isVisibleTo')->getId()); $this->assertInstanceOf(IRI::class, $this->reader->getFirstValueIRI($object, 'coid://cloudobjects.io/isVisibleTo'));
$this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getFirstValueNode($object, 'co:isVisibleTo')->getId()); $this->assertInstanceOf(IRI::class, $this->reader->getFirstValueIRI($object, 'co:isVisibleTo'));
}
public function testGetAllValuesString1() { $this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getFirstValueIRI($object, 'coid://cloudobjects.io/isVisibleTo'));
$coid = new IRI('coid://cloudobjects.io'); $this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getFirstValueIRI($object, 'co:isVisibleTo'));
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertCount(1, $this->reader->getAllValuesString($object, 'http://www.w3.org/2000/01/rdf-schema#label')); $object = $this->retriever->getCloudObject($coid);
$this->assertCount(1, $this->reader->getAllValuesString($object, 'rdfs:label'));
$this->assertEquals('CloudObjects', $this->reader->getAllValuesString($object, 'http://www.w3.org/2000/01/rdf-schema#label')[0]); $this->assertInstanceOf(IRI::class, $object->getIRI('coid://cloudobjects.io/isVisibleTo'));
$this->assertEquals('CloudObjects', $this->reader->getAllValuesString($object, 'rdfs:label')[0]); $this->assertInstanceOf(IRI::class, $object->getIRI('co:isVisibleTo'));
$this->assertCount(0, $this->reader->getAllValuesString($object, 'coid://cloudobjects.io/makesTriplesVisibleTo')); $this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $object->getIRI('coid://cloudobjects.io/isVisibleTo'));
$this->assertCount(0, $this->reader->getAllValuesString($object, 'co:makesTriplesVisibleTo')); $this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $object->getIRI('co:isVisibleTo'));
}
$this->assertCount(2, $this->reader->getAllValuesString($object, '@type')); public function testGetFirstValueNode1() {
} $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
public function testGetAllValuesIRI1() { $this->assertInstanceOf(Node::class, $this->reader->getFirstValueNode($object, 'coid://cloudobjects.io/isVisibleTo'));
$coid = new IRI('coid://cloudobjects.io'); $this->assertInstanceOf(Node::class, $this->reader->getFirstValueNode($object, 'co:isVisibleTo'));
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertCount(0, $this->reader->getAllValuesIRI($object, 'http://www.w3.org/2000/01/rdf-schema#label')); $this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getFirstValueNode($object, 'coid://cloudobjects.io/isVisibleTo')->getId());
$this->assertCount(0, $this->reader->getAllValuesIRI($object, 'rdfs:label')); $this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getFirstValueNode($object, 'co:isVisibleTo')->getId());
$this->assertCount(1, $this->reader->getAllValuesIRI($object, 'coid://cloudobjects.io/isVisibleTo')); $object = $this->retriever->getCloudObject($coid);
$this->assertCount(1, $this->reader->getAllValuesIRI($object, 'co:isVisibleTo'));
$this->assertCount(2, $this->reader->getAllValuesIRI($object, '@type')); $this->assertInstanceOf(Node::class, $object->getNode('coid://cloudobjects.io/isVisibleTo'));
$this->assertInstanceOf(Node::class, $object->getNode('co:isVisibleTo'));
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getAllValuesIRI($object, 'coid://cloudobjects.io/isVisibleTo')[0]); $this->assertEquals('coid://cloudobjects.io/Public', $object->getNode('coid://cloudobjects.io/isVisibleTo')->getId());
$this->assertInstanceOf('ML\IRI\IRI', $this->reader->getAllValuesIRI($object, 'co:isVisibleTo')[0]); $this->assertEquals('coid://cloudobjects.io/Public', $object->getNode('co:isVisibleTo')->getId());
}
$this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getAllValuesIRI($object, 'coid://cloudobjects.io/isVisibleTo')[0]); public function testGetAllValuesString1() {
$this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getAllValuesIRI($object, 'co:isVisibleTo')[0]); $coid = new IRI('coid://cloudobjects.io');
} $this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
public function testGetAllValuesNode1() { $this->assertCount(1, $this->reader->getAllValuesString($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
$coid = new IRI('coid://cloudobjects.io'); $this->assertCount(1, $this->reader->getAllValuesString($object, 'rdfs:label'));
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'http://www.w3.org/2000/01/rdf-schema#label')); $this->assertEquals('CloudObjects', $this->reader->getAllValuesString($object, 'http://www.w3.org/2000/01/rdf-schema#label')[0]);
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'rdfs:label')); $this->assertEquals('CloudObjects', $this->reader->getAllValuesString($object, 'rdfs:label')[0]);
$this->assertCount(1, $this->reader->getAllValuesNode($object, 'coid://cloudobjects.io/isVisibleTo')); $this->assertCount(0, $this->reader->getAllValuesString($object, 'coid://cloudobjects.io/makesTriplesVisibleTo'));
$this->assertCount(1, $this->reader->getAllValuesNode($object, 'co:isVisibleTo')); $this->assertCount(0, $this->reader->getAllValuesString($object, 'co:makesTriplesVisibleTo'));
$this->assertCount(2, $this->reader->getAllValuesNode($object, '@type')); $this->assertCount(2, $this->reader->getAllValuesString($object, '@type'));
}
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getAllValuesNode($object, 'coid://cloudobjects.io/isVisibleTo')[0]); public function testGetAllValuesIRI1() {
$this->assertInstanceOf('ML\JsonLD\Node', $this->reader->getAllValuesNode($object, 'co:isVisibleTo')[0]); $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getAllValuesNode($object, 'coid://cloudobjects.io/isVisibleTo')[0]->getId()); $this->assertCount(0, $this->reader->getAllValuesIRI($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
$this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getAllValuesNode($object, 'co:isVisibleTo')[0]->getId()); $this->assertCount(0, $this->reader->getAllValuesIRI($object, 'rdfs:label'));
}
$this->assertCount(1, $this->reader->getAllValuesIRI($object, 'coid://cloudobjects.io/isVisibleTo'));
$this->assertCount(1, $this->reader->getAllValuesIRI($object, 'co:isVisibleTo'));
$this->assertCount(2, $this->reader->getAllValuesIRI($object, '@type'));
$this->assertInstanceOf(IRI::class, $this->reader->getAllValuesIRI($object, 'coid://cloudobjects.io/isVisibleTo')[0]);
$this->assertInstanceOf(IRI::class, $this->reader->getAllValuesIRI($object, 'co:isVisibleTo')[0]);
$this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getAllValuesIRI($object, 'coid://cloudobjects.io/isVisibleTo')[0]);
$this->assertEquals(new IRI('coid://cloudobjects.io/Public'), $this->reader->getAllValuesIRI($object, 'co:isVisibleTo')[0]);
}
public function testGetAllValuesNode1() {
$coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock();
$object = $this->retriever->getObjectNode($coid);
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'http://www.w3.org/2000/01/rdf-schema#label'));
$this->assertCount(0, $this->reader->getAllValuesNode($object, 'rdfs:label'));
$this->assertCount(1, $this->reader->getAllValuesNode($object, 'coid://cloudobjects.io/isVisibleTo'));
$this->assertCount(1, $this->reader->getAllValuesNode($object, 'co:isVisibleTo'));
$this->assertCount(2, $this->reader->getAllValuesNode($object, '@type'));
$this->assertInstanceOf(Node::class, $this->reader->getAllValuesNode($object, 'coid://cloudobjects.io/isVisibleTo')[0]);
$this->assertInstanceOf(Node::class, $this->reader->getAllValuesNode($object, 'co:isVisibleTo')[0]);
$this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getAllValuesNode($object, 'coid://cloudobjects.io/isVisibleTo')[0]->getId());
$this->assertEquals('coid://cloudobjects.io/Public', $this->reader->getAllValuesNode($object, 'co:isVisibleTo')[0]->getId());
}
} }

View File

@@ -43,7 +43,7 @@ class ObjectRetrieverMockTest extends \PHPUnit\Framework\TestCase {
// Test CloudObject interface // Test CloudObject interface
$object = $this->retriever->getCloudObject($coid); $object = $this->retriever->getCloudObject($coid);
$this->assertNotNull($object); $this->assertNotNull($object);
$this->assertEquals((string)$coid, $object->getObjectNode()->getID()); $this->assertEquals((string)$coid, $object->getObjectNode()->getId());
$this->assertEquals($coid, $object->getCOID()); $this->assertEquals($coid, $object->getCOID());
$this->assertNotNull($object->getString('http://www.w3.org/2000/01/rdf-schema#label')); $this->assertNotNull($object->getString('http://www.w3.org/2000/01/rdf-schema#label'));
$this->assertEquals('CloudObjects', $object->getString('http://www.w3.org/2000/01/rdf-schema#label')); $this->assertEquals('CloudObjects', $object->getString('http://www.w3.org/2000/01/rdf-schema#label'));

View File

@@ -28,11 +28,23 @@ class ObjectRetrieverPublicTest extends \PHPUnit\Framework\TestCase {
$coid = new IRI('coid://cloudobjects.io'); $coid = new IRI('coid://cloudobjects.io');
$object = $this->retriever->getObjectNode($coid); $object = $this->retriever->getObjectNode($coid);
$this->assertNotNull($object); $this->assertNotNull($object);
$this->assertEquals((string)$coid, $object->getID()); $this->assertEquals((string)$coid, $object->getId());
$this->assertNotNull($object->getProperty('http://www.w3.org/2000/01/rdf-schema#label')); $this->assertNotNull($object->getProperty('http://www.w3.org/2000/01/rdf-schema#label'));
$this->assertEquals('CloudObjects', $object->getProperty('http://www.w3.org/2000/01/rdf-schema#label')->getValue()); $this->assertEquals('CloudObjects', $object->getProperty('http://www.w3.org/2000/01/rdf-schema#label')->getValue());
} }
public function testGetRelatedObject() {
$coid = new IRI('coid://cloudobjects.io');
$object = $this->retriever->getCloudObject($coid);
$this->assertNotNull($object);
$this->assertNotNull($object->getIRI('coid://cloudobjects.io/isVisibleTo'));
$this->assertEquals('coid://cloudobjects.io/Public', $object->getString('coid://cloudobjects.io/isVisibleTo'));
$relatedObject = $object->getCloudObject('coid://cloudobjects.io/isVisibleTo');
$this->assertNotNull($relatedObject);
$this->assertEquals('coid://cloudobjects.io/Public', (string)$relatedObject->getCOID());
}
public function testGetCOIDList() { public function testGetCOIDList() {
$coid = new IRI('coid://cloudobjects.io'); $coid = new IRI('coid://cloudobjects.io');
$list = $this->stringifyItems( $list = $this->stringifyItems(