server/src/tests/libraries/Mappers/CocoonCollectionRdfMapperTest.php
changeset 144 03678acbfda3
parent 114 8af5ed0521a2
child 145 49b75287c30b
equal deleted inserted replaced
143:023b6d467566 144:03678acbfda3
    51             <http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ALA> .
    51             <http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ALA> .
    52 EOT
    52 EOT
    53     ];
    53     ];
    54 
    54 
    55     const TEST_INPUT_ID = "crdo-COLLECTION_CFPP2000";
    55     const TEST_INPUT_ID = "crdo-COLLECTION_CFPP2000";
    56     const TEST_GRAPH_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000";
       
    57 
    56 
    58     private $inputGraphes = [];
    57     private $inputGraphes = [];
    59     private $resGraphes = [];
    58     private $resGraphes = [];
    60     private $mappers = [];
    59     private $mappers = [];
    61 
    60 
    63         parent::__construct($name);
    62         parent::__construct($name);
    64     }
    63     }
    65 
    64 
    66     public function setUp() {
    65     public function setUp() {
    67         parent::setUp();
    66         parent::setUp();
       
    67 
       
    68         $this->testGraphUri = config('corpusparole.corpus_doc_id_base_uri').CocoonCollectionRdfMapperTest::TEST_INPUT_ID;
    68 
    69 
    69         foreach(CocoonCollectionRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) {
    70         foreach(CocoonCollectionRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) {
    70             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000", $inputDoc);
    71             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_CFPP2000", $inputDoc);
    71             $this->mappers[$key] = new CocoonCollectionRdfMapper($this->inputGraphes[$key]);
    72             $this->mappers[$key] = new CocoonCollectionRdfMapper($this->inputGraphes[$key]);
    72             $this->mappers[$key]->mapGraph();
    73             $this->mappers[$key]->mapGraph();
    97 
    98 
    98         //echo $this->resGraphes['BASE']->serialise('turtle');
    99         //echo $this->resGraphes['BASE']->serialise('turtle');
    99         //echo var_export($this->resGraphes['BASE']->toRdfPhp());
   100         //echo var_export($this->resGraphes['BASE']->toRdfPhp());
   100 
   101 
   101         $this->assertNotNull($this->resGraphes['BASE']);
   102         $this->assertNotNull($this->resGraphes['BASE']);
   102         $this->assertEquals(CocoonCollectionRdfMapperTest::TEST_GRAPH_URI, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
   103         $this->assertEquals($this->testGraphUri, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
   103      }
   104      }
   104 
   105 
   105     /**
   106     /**
   106       * Test that the return graph has one edm:Collection resource
   107       * Test that the return graph has one edm:Collection resource
   107       *
   108       *
   110     public function testAggregationResource() {
   111     public function testAggregationResource() {
   111 
   112 
   112         $resources = $this->resGraphes['BASE']->allOfType('edm:Collection');
   113         $resources = $this->resGraphes['BASE']->allOfType('edm:Collection');
   113 
   114 
   114         $this->assertCount(1, $resources, "Must found only one resources of type edm:Collection");
   115         $this->assertCount(1, $resources, "Must found only one resources of type edm:Collection");
   115         $this->assertEquals(CocoonCollectionRdfMapperTest::TEST_GRAPH_URI,$resources[0]);
   116         $this->assertEquals($this->testGraphUri,$resources[0]);
   116     }
   117     }
   117 
   118 
   118     /**
   119     /**
   119     * Test one to one mapping spatial info
   120     * Test one to one mapping spatial info
   120     *
   121     *
   198             }
   199             }
   199         }
   200         }
   200 
   201 
   201     }
   202     }
   202 
   203 
       
   204     public function testLinkToCocoonCollection() {
       
   205         $coll = $this->resGraphes['BASE']->get('edm:Collection', '^rdf:type');
       
   206         $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   207 
       
   208         $this->assertNotNull($coll);
       
   209         $this->assertNotNull($sourceNode);
       
   210 
       
   211         $versionOfRes = $coll->all("<http://purl.org/dc/terms/isVersionOf>");
       
   212         $this->assertCount(1, $versionOfRes, "Must have only on isVersionOf");
       
   213         $versionOfRes = $versionOfRes[0];
       
   214         $this->assertInstanceOf("EasyRdf\Resource", $versionOfRes, "version Res must be a resource");
       
   215         $this->assertEquals($sourceNode->getUri(), $versionOfRes->getUri(), "versionof res uri must be sams than source");
       
   216 
       
   217     }
       
   218 
   203 }
   219 }