server/src/tests/libraries/Mappers/CocoonTextRdfMapperTest.php
changeset 143 023b6d467566
parent 125 e550b10fe3ca
equal deleted inserted replaced
142:86fcf0c837c0 143:023b6d467566
    48             <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_archive> .
    48             <http://purl.org/dc/terms/conformsTo> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-dtd_archive> .
    49 EOT
    49 EOT
    50     ];
    50     ];
    51 
    51 
    52     const TEST_INPUT_ID = "crdo-UVE_MOCIKA_SOUND";
    52     const TEST_INPUT_ID = "crdo-UVE_MOCIKA_SOUND";
    53     const TEST_GRAPH_URI = "http://corpusdelaparole.huma-num.fr/corpus/res/crdo-UVE_MOCIKA_SOUND";
       
    54     const TEST_CHO_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND";
    53     const TEST_CHO_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND";
    55 
    54 
    56 
    55 
    57     private $inputGraphes = [];
    56     private $inputGraphes = [];
    58     private $resGraphes = [];
    57     private $resGraphes = [];
    63     }
    62     }
    64 
    63 
    65     public function setUp() {
    64     public function setUp() {
    66         parent::setUp();
    65         parent::setUp();
    67 
    66 
       
    67         $this->testGraphUri = config('corpusparole.corpus_doc_id_base_uri').CocoonTextRdfMapperTest::TEST_INPUT_ID;
    68         foreach(CocoonTextRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) {
    68         foreach(CocoonTextRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) {
    69             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA", $inputDoc);
    69             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA", $inputDoc);
    70             $this->mappers[$key] = new CocoonTextRdfMapper($this->inputGraphes[$key]);
    70             $this->mappers[$key] = new CocoonTextRdfMapper($this->inputGraphes[$key]);
    71             $this->mappers[$key]->mapGraph();
    71             $this->mappers[$key]->mapGraph();
    72             $this->resGraphes[$key] = $this->mappers[$key]->getOutputGraphes()["http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND"];
    72             $this->resGraphes[$key] = $this->mappers[$key]->getOutputGraphes()["http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND"];
    97 
    97 
    98         //echo $this->resGraphes['BASE']->serialise('turtle');
    98         //echo $this->resGraphes['BASE']->serialise('turtle');
    99         //echo var_export($this->resGraphes['BASE']->toRdfPhp());
    99         //echo var_export($this->resGraphes['BASE']->toRdfPhp());
   100 
   100 
   101         $this->assertNotNull($this->resGraphes['BASE']);
   101         $this->assertNotNull($this->resGraphes['BASE']);
   102         $this->assertEquals(CocoonTextRdfMapperTest::TEST_GRAPH_URI, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
   102         $this->assertEquals($this->testGraphUri, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
   103     }
   103     }
   104 
   104 
   105     /**
   105     /**
   106      * Test that the return graph has one ore:Aggregation resource
   106      * Test that the return graph has one ore:Aggregation resource
   107      *
   107      *
   110     public function testAggregationResource() {
   110     public function testAggregationResource() {
   111 
   111 
   112         $resources = $this->resGraphes['BASE']->allOfType('ore:Aggregation');
   112         $resources = $this->resGraphes['BASE']->allOfType('ore:Aggregation');
   113 
   113 
   114         $this->assertCount(1, $resources, "Must found only one resources of type ore:Aggregation");
   114         $this->assertCount(1, $resources, "Must found only one resources of type ore:Aggregation");
   115         $this->assertEquals(CocoonTextRdfMapperTest::TEST_GRAPH_URI,$resources[0]->getUri());
   115         $this->assertEquals($this->testGraphUri,$resources[0]->getUri());
   116     }
   116     }
   117 
   117 
   118     /**
   118     /**
   119      * Test providedCHO identifier.
   119      * Test providedCHO identifier.
   120      *
   120      *
   227 
   227 
   228         $resources = $this->resGraphes['BASE']->allOfType('edm:WebResource');
   228         $resources = $this->resGraphes['BASE']->allOfType('edm:WebResource');
   229 
   229 
   230         $this->assertCount(2, $resources, "Must found three webresource");
   230         $this->assertCount(2, $resources, "Must found three webresource");
   231 
   231 
   232         $aggregation = $this->resGraphes['BASE']->resource(CocoonTextRdfMapperTest::TEST_GRAPH_URI);
   232         $aggregation = $this->resGraphes['BASE']->resource($this->testGraphUri);
   233 
   233 
   234         foreach ($resources as $wres) {
   234         foreach ($resources as $wres) {
   235             $mimetypes = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/format'));
   235             $mimetypes = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/format'));
   236             $this->assertCount(1, $mimetypes, "Must find one mimetype.");
   236             $this->assertCount(1, $mimetypes, "Must find one mimetype.");
   237             $mimetype = $mimetypes[0];
   237             $mimetype = $mimetypes[0];