server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php
changeset 144 03678acbfda3
parent 114 8af5ed0521a2
child 145 49b75287c30b
--- a/server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php	Fri Mar 25 17:03:45 2016 +0100
+++ b/server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php	Sat Mar 26 00:24:34 2016 +0100
@@ -53,7 +53,6 @@
     ];
 
     const TEST_INPUT_ID = "crdo-COLLECTION_CFPP2000";
-    const TEST_GRAPH_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000";
 
     private $inputGraphes = [];
     private $resGraphes = [];
@@ -66,6 +65,8 @@
     public function setUp() {
         parent::setUp();
 
+        $this->testGraphUri = config('corpusparole.corpus_doc_id_base_uri').CocoonCollectionRdfMapperTest::TEST_INPUT_ID;
+
         foreach(CocoonCollectionRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) {
             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000", $inputDoc);
             $this->mappers[$key] = new CocoonCollectionRdfMapper($this->inputGraphes[$key]);
@@ -99,7 +100,7 @@
         //echo var_export($this->resGraphes['BASE']->toRdfPhp());
 
         $this->assertNotNull($this->resGraphes['BASE']);
-        $this->assertEquals(CocoonCollectionRdfMapperTest::TEST_GRAPH_URI, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
+        $this->assertEquals($this->testGraphUri, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
      }
 
     /**
@@ -112,7 +113,7 @@
         $resources = $this->resGraphes['BASE']->allOfType('edm:Collection');
 
         $this->assertCount(1, $resources, "Must found only one resources of type edm:Collection");
-        $this->assertEquals(CocoonCollectionRdfMapperTest::TEST_GRAPH_URI,$resources[0]);
+        $this->assertEquals($this->testGraphUri,$resources[0]);
     }
 
     /**
@@ -200,4 +201,19 @@
 
     }
 
+    public function testLinkToCocoonCollection() {
+        $coll = $this->resGraphes['BASE']->get('edm:Collection', '^rdf:type');
+        $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
+
+        $this->assertNotNull($coll);
+        $this->assertNotNull($sourceNode);
+
+        $versionOfRes = $coll->all("<http://purl.org/dc/terms/isVersionOf>");
+        $this->assertCount(1, $versionOfRes, "Must have only on isVersionOf");
+        $versionOfRes = $versionOfRes[0];
+        $this->assertInstanceOf("EasyRdf\Resource", $versionOfRes, "version Res must be a resource");
+        $this->assertEquals($sourceNode->getUri(), $versionOfRes->getUri(), "versionof res uri must be sams than source");
+
+    }
+
 }