server/src/tests/libraries/Mergers/CocoonTextRdfMergerTest.php
changeset 152 dd6b3adde73b
parent 151 95dfb40ff3d2
child 153 338bcc78d431
equal deleted inserted replaced
151:95dfb40ff3d2 152:dd6b3adde73b
     1 <?php
       
     2 
       
     3 use CorpusParole\Libraries\Mergers\CocoonSoundRdfMerger;
       
     4 use CorpusParole\Libraries\Mergers\CocoonTextRdfMerger;
       
     5 use CorpusParole\Libraries\CocoonUtils;
       
     6 
       
     7 use EasyRdf\Graph;
       
     8 use EasyRdf\Resource;
       
     9 use EasyRdf\Literal;
       
    10 
       
    11 use Illuminate\Foundation\Testing\WithoutMiddleware;
       
    12 use Illuminate\Foundation\Testing\DatabaseMigrations;
       
    13 use Illuminate\Foundation\Testing\DatabaseTransactions;
       
    14 
       
    15 class CocoonTextRdfMergerTest extends TestCase
       
    16 {
       
    17 
       
    18     const TEST_INPUT_DOCS = [
       
    19         'SOUND' => <<<EOT
       
    20         @prefix ore: <http://www.openarchives.org/ore/terms/> .
       
    21         @prefix edm: <http://www.europeana.eu/schemas/edm/> .
       
    22         @prefix dc11: <http://purl.org/dc/elements/1.1/> .
       
    23         @prefix olac: <http://www.language-archives.org/OLAC/1.1/> .
       
    24         @prefix dc: <http://purl.org/dc/terms/> .
       
    25         @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
       
    26         @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
       
    27         @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
       
    28         @prefix owl: <http://www.w3.org/2002/07/owl#> .
       
    29 
       
    30         <http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-UVE_MOCIKA_SOUND>
       
    31           a ore:Aggregation ;
       
    32           edm:aggregatedCHO <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND> ;
       
    33           edm:provider "Corpus de la Parole"@fr ;
       
    34           edm:dataProvider "Laboratoire de langues et civilisations à tradition orale" ;
       
    35           edm:isShownAt <http://cocoon.huma-num.fr/exist/crdo/meta/crdo-UVE_MOCIKA_SOUND> ;
       
    36           edm:isShownBy <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
    37           edm:rights <http://creativecommons.org/licenses/by-nc-nd/4.0/> ;
       
    38           edm:hasView <http://cocoon.huma-num.fr/data/archi/144187_MOCIKA_22km.wav>, <http://cocoon.huma-num.fr/data/archi/mp3/144187_MOCIKA_44k.mp3> .
       
    39 
       
    40         <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND>
       
    41           a edm:ProvidedCHO ;
       
    42           dc:identifier "crdo-UVE_MOCIKA_SOUND" ;
       
    43           dc11:description "Voilà pourquoi le bernard-l'hermite, aujourd'hui, se cache dans les coquilles vides qu'il trouve, alors que le crabe de cocotier n'a pas honte de se promener tout nu."@fr ;
       
    44           dc11:language <http://lexvo.org/id/iso639-3/uve> ;
       
    45           dc11:publisher "Laboratoire de langues et civilisations à tradition orale" ;
       
    46           dc11:rights "Copyright (c) Moyse-Faurie, Claire" ;
       
    47           dc11:type <http://purl.org/dc/dcmitype/Sound>, "primary_text"^^olac:linguistic-type, "narrative"^^olac:discourse-type, <http://ark.bnf.fr/ark:/12148/cb11937212q> ;
       
    48           dc:license <http://creativecommons.org/licenses/by-nc-nd/2.5/> ;
       
    49           dc11:subject <http://ark.bnf.fr/ark:/12148/cb11958119h>, <http://lexvo.org/id/iso639-3/uve>, <http://ark.bnf.fr/ark:/12148/cb11953067w> ;
       
    50           dc11:title "The two hermit crabs and the coconut crab"@en ;
       
    51           dc:accessRights "Freely available for non-commercial use" ;
       
    52           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ;
       
    53           dc:extent "PT2M35S" ;
       
    54           edm:isGatheredInto <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE>, <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LACITO> ;
       
    55           olac:depositor <http://viaf.org/viaf/56614135> ;
       
    56           dc11:contributor <http://viaf.org/viaf/56614135>, "Idakote, Félicien" ;
       
    57           olac:researcher <http://viaf.org/viaf/56614135> ;
       
    58           olac:speaker "Idakote, Félicien" ;
       
    59           dc:available "2010-10-23"^^dc:W3CDTF ;
       
    60           dc:created "1997-08-29"^^dc:W3CDTF ;
       
    61           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
    62           dc:modified "2012-03-25"^^dc:W3CDTF ;
       
    63           dc:spatial [
       
    64             a edm:Place ;
       
    65             geo:lat "-20.46667"^^xsd:float ;
       
    66             geo:long "166.65"^^xsd:float ;
       
    67             skos:note "NC"^^dc:ISO3166, "New Caledonia, Ohnyat (Ouvéa)" ;
       
    68             owl:sameAs <http://sws.geonames.org/2139490/>
       
    69           ] .
       
    70 
       
    71         <http://cocoon.huma-num.fr/data/archi/masters/144187.wav>
       
    72           a edm:WebResource ;
       
    73           dc:extent "PT2M35S" ;
       
    74           dc11:format "audio/x-wav"^^dc:IMT ;
       
    75           dc:created "1997-08-29"^^dc:W3CDTF ;
       
    76           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
    77           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
    78           dc:accessRights "Freely available for non-commercial use" ;
       
    79           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
    80 
       
    81 
       
    82         <http://cocoon.huma-num.fr/data/archi/144187_MOCIKA_22km.wav>
       
    83           a edm:WebResource ;
       
    84           dc:extent "PT2M35S" ;
       
    85           dc11:format "audio/x-wav"^^dc:IMT ;
       
    86           edm:isDerivativeOf <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
    87           dc:created "1997-08-29"^^dc:W3CDTF ;
       
    88           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
    89           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
    90           dc:accessRights "Freely available for non-commercial use" ;
       
    91           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
    92 
       
    93 
       
    94         <http://cocoon.huma-num.fr/data/archi/mp3/144187_MOCIKA_44k.mp3>
       
    95           a edm:WebResource ;
       
    96           dc:extent "PT2M35S" ;
       
    97           dc11:format "audio/mpeg"^^dc:IMT ;
       
    98           edm:isDerivativeOf <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
    99           dc:created "1997-08-29"^^dc:W3CDTF ;
       
   100           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
   101           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   102           dc:accessRights "Freely available for non-commercial use" ;
       
   103           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
   104 
       
   105 EOT
       
   106         ,
       
   107         'SOUND_NO_MOD' => <<<EOT
       
   108         @prefix ore: <http://www.openarchives.org/ore/terms/> .
       
   109         @prefix edm: <http://www.europeana.eu/schemas/edm/> .
       
   110         @prefix dc11: <http://purl.org/dc/elements/1.1/> .
       
   111         @prefix olac: <http://www.language-archives.org/OLAC/1.1/> .
       
   112         @prefix dc: <http://purl.org/dc/terms/> .
       
   113         @prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
       
   114         @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
       
   115         @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
       
   116         @prefix owl: <http://www.w3.org/2002/07/owl#> .
       
   117 
       
   118         <http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-UVE_MOCIKA_SOUND>
       
   119           a ore:Aggregation ;
       
   120           edm:aggregatedCHO <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND> ;
       
   121           edm:provider "Corpus de la Parole"@fr ;
       
   122           edm:dataProvider "Laboratoire de langues et civilisations à tradition orale" ;
       
   123           edm:isShownAt <http://cocoon.huma-num.fr/exist/crdo/meta/crdo-UVE_MOCIKA_SOUND> ;
       
   124           edm:isShownBy <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
   125           edm:rights <http://creativecommons.org/licenses/by-nc-sa/4.0/> ;
       
   126           edm:hasView <http://cocoon.huma-num.fr/data/archi/144187_MOCIKA_22km.wav>, <http://cocoon.huma-num.fr/data/archi/mp3/144187_MOCIKA_44k.mp3> .
       
   127 
       
   128         <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND>
       
   129           a edm:ProvidedCHO ;
       
   130           dc:identifier "crdo-UVE_MOCIKA_SOUND" ;
       
   131           dc11:description "Voilà pourquoi le bernard-l'hermite, aujourd'hui, se cache dans les coquilles vides qu'il trouve, alors que le crabe de cocotier n'a pas honte de se promener tout nu."@fr ;
       
   132           dc11:language <http://lexvo.org/id/iso639-3/uve> ;
       
   133           dc11:publisher "Laboratoire de langues et civilisations à tradition orale" ;
       
   134           dc11:rights "Copyright (c) Moyse-Faurie, Claire" ;
       
   135           dc11:type <http://purl.org/dc/dcmitype/Sound>, "primary_text"^^olac:linguistic-type, "narrative"^^olac:discourse-type, <http://ark.bnf.fr/ark:/12148/cb11937212q> ;
       
   136           dc:license <http://creativecommons.org/licenses/by-nc-nd/2.5/> ;
       
   137           dc11:subject <http://ark.bnf.fr/ark:/12148/cb11958119h>, <http://lexvo.org/id/iso639-3/uve>, <http://ark.bnf.fr/ark:/12148/cb11953067w> ;
       
   138           dc11:title "The two hermit crabs and the coconut crab"@en ;
       
   139           dc:accessRights "Freely available for non-commercial use" ;
       
   140           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ;
       
   141           dc:extent "PT2M35S" ;
       
   142           edm:isGatheredInto <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE>, <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LACITO> ;
       
   143           olac:depositor <http://viaf.org/viaf/56614135> ;
       
   144           dc11:contributor <http://viaf.org/viaf/56614135>, "Idakote, Félicien" ;
       
   145           olac:researcher <http://viaf.org/viaf/56614135> ;
       
   146           olac:speaker "Idakote, Félicien" ;
       
   147           dc:available "2010-10-23"^^dc:W3CDTF ;
       
   148           dc:created "1997-08-29"^^dc:W3CDTF ;
       
   149           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
   150           dc:spatial [
       
   151             a edm:Place ;
       
   152             geo:lat "-20.46667"^^xsd:float ;
       
   153             geo:long "166.65"^^xsd:float ;
       
   154             skos:note "NC"^^dc:ISO3166, "New Caledonia, Ohnyat (Ouvéa)" ;
       
   155             owl:sameAs <http://sws.geonames.org/2139490/>
       
   156           ] .
       
   157 
       
   158         <http://cocoon.huma-num.fr/data/archi/masters/144187.wav>
       
   159           a edm:WebResource ;
       
   160           dc:extent "PT2M35S" ;
       
   161           dc11:format "audio/x-wav"^^dc:IMT ;
       
   162           dc:created "1997-08-29"^^dc:W3CDTF ;
       
   163           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
   164           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   165           dc:accessRights "Freely available for non-commercial use" ;
       
   166           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
   167 
       
   168 
       
   169         <http://cocoon.huma-num.fr/data/archi/144187_MOCIKA_22km.wav>
       
   170           a edm:WebResource ;
       
   171           dc:extent "PT2M35S" ;
       
   172           dc11:format "audio/x-wav"^^dc:IMT ;
       
   173           edm:isDerivativeOf <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
   174           dc:created "1997-08-29"^^dc:W3CDTF ;
       
   175           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
   176           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   177           dc:accessRights "Freely available for non-commercial use" ;
       
   178           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
   179 
       
   180 
       
   181         <http://cocoon.huma-num.fr/data/archi/mp3/144187_MOCIKA_44k.mp3>
       
   182           a edm:WebResource ;
       
   183           dc:extent "PT2M35S" ;
       
   184           dc11:format "audio/mpeg"^^dc:IMT ;
       
   185           edm:isDerivativeOf <http://cocoon.huma-num.fr/data/archi/masters/144187.wav> ;
       
   186           dc:created "1997-08-29"^^dc:W3CDTF ;
       
   187           dc:issued "2010-10-23T00:08:27+02:00"^^dc:W3CDTF ;
       
   188           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   189           dc:accessRights "Freely available for non-commercial use" ;
       
   190           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
   191 
       
   192 EOT
       
   193         ,
       
   194         'TEXT' => <<<EOT
       
   195         @prefix ore: <http://www.openarchives.org/ore/terms/> .
       
   196         @prefix edm: <http://www.europeana.eu/schemas/edm/> .
       
   197         @prefix dc11: <http://purl.org/dc/elements/1.1/> .
       
   198         @prefix olac: <http://www.language-archives.org/OLAC/1.1/> .
       
   199         @prefix dc: <http://purl.org/dc/terms/> .
       
   200         @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
       
   201 
       
   202         <http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-UVE_MOCIKA_SOUND>
       
   203           a ore:Aggregation ;
       
   204           edm:aggregatedCHO <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND> ;
       
   205           edm:provider "Corpus de la Parole"@fr ;
       
   206           edm:dataProvider <http://viaf.org/viaf/154919513> ;
       
   207           edm:isShownAt <http://cocoon.huma-num.fr/exist/crdo/meta/crdo-UVE_MOCIKA_SOUND> ;
       
   208           edm:isShownBy <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xml> ;
       
   209           edm:rights <http://creativecommons.org/licenses/by-nc-sa/4.0/> ;
       
   210           edm:hasView <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xml>, <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xhtml> .
       
   211 
       
   212         <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-UVE_MOCIKA_SOUND>
       
   213           a edm:ProvidedCHO ;
       
   214           dc:identifier "crdo-UVE_MOCIKA_SOUND" ;
       
   215           dc11:description "Voilà pourquoi le bernard-l'hermite, aujourd'hui, se cache dans les coquilles vides qu'il trouve, alors que le crabe de cocotier n'a pas honte de se promener tout nu."@fr ;
       
   216           dc11:language <http://lexvo.org/id/iso639-3/uve> ;
       
   217           dc11:publisher <http://viaf.org/viaf/154919513> ;
       
   218           dc11:rights "Copyright (c) Moyse-Faurie, Claire" ;
       
   219           dc11:type "primary_text"^^olac:linguistic-type, <http://purl.org/dc/dcmitype/Text>, "narrative"^^olac:discourse-type ;
       
   220           dc:license <http://creativecommons.org/licenses/by-nc-sa/2.5/> ;
       
   221           dc11:subject <http://lexvo.org/id/iso639-3/uve> ;
       
   222           dc11:title "The two hermit crabs and the coconut crab"@en ;
       
   223           dc:accessRights "Freely available for non-commercial use" ;
       
   224           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" ;
       
   225           edm:isGatheredInto <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE>, <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LACITO> ;
       
   226           dc:alternative "Les deux bernard-l'hermite et le crabe de cocotier"@fr ;
       
   227           olac:depositor <http://viaf.org/viaf/56614135> ;
       
   228           dc11:contributor <http://viaf.org/viaf/56614135>, "Moyse-Faurie, Claire", "Idakote, Félicien" ;
       
   229           olac:researcher "Moyse-Faurie, Claire" ;
       
   230           olac:speaker "Idakote, Félicien" ;
       
   231           dc:available "2011-02-05"^^dc:W3CDTF ;
       
   232           dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF ;
       
   233           dc:modified "2002-02-20"^^dc:W3CDTF ;
       
   234           dc:spatial [
       
   235             a edm:Place ;
       
   236             skos:note "NC"^^dc:ISO3166, "New Caledonia, Ohnyat (Ouvéa)"
       
   237           ] .
       
   238 
       
   239         <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xml>
       
   240           a edm:WebResource ;
       
   241           dc11:format "application/xml"^^dc:IMT ;
       
   242           dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF ;
       
   243           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   244           dc:accessRights "Freely available for non-commercial use" ;
       
   245           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
   246 
       
   247 
       
   248         <http://cocoon.huma-num.fr/exist/crdo/moyse-faurie/uve/crdo-UVE_MOCIKA.xhtml>
       
   249           a edm:WebResource ;
       
   250           dc11:format "application/xhtml+xml"^^dc:IMT ;
       
   251           dc:issued "2011-02-05T23:22:23+01:00"^^dc:W3CDTF ;
       
   252           dc:license <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   253           dc:accessRights "Freely available for non-commercial use" ;
       
   254           dc11:rights "Copyright (c) 2012 Université d'Orléans/LLL" .
       
   255 
       
   256 EOT
       
   257     ];
       
   258 
       
   259 
       
   260     private $inputGraphes = [];
       
   261     private $resGraph = [];
       
   262 
       
   263     function __construct(string $name = null) {
       
   264         parent::__construct($name);
       
   265     }
       
   266 
       
   267     public function setUp() {
       
   268         parent::setUp();
       
   269 
       
   270         foreach(CocoonTextRdfMergerTest::TEST_INPUT_DOCS as $key => $inputDoc) {
       
   271             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND", $inputDoc);
       
   272         }
       
   273 
       
   274         $merger = new CocoonTextRdfMerger();
       
   275         $this->resGraph['SOUND_TEXT'] = $merger->mergeGraph($this->inputGraphes['SOUND'], $this->inputGraphes['TEXT']);
       
   276         $merger = new CocoonSoundRdfMerger();
       
   277         $this->resGraph['TEXT_SOUND'] = $merger->mergeGraph($this->inputGraphes['TEXT'], $this->inputGraphes['SOUND']);
       
   278         $merger = new CocoonTextRdfMerger();
       
   279         $this->resGraph['SOUND_NO_MOD_TEXT'] = $merger->mergeGraph($this->inputGraphes['SOUND_NO_MOD'], $this->inputGraphes['TEXT']);
       
   280         $merger = new CocoonSoundRdfMerger();
       
   281         $this->resGraph['TEXT_SOUND_NO_MOD'] = $merger->mergeGraph($this->inputGraphes['TEXT'], $this->inputGraphes['SOUND_NO_MOD']);
       
   282     }
       
   283 
       
   284     public function tearDown() {
       
   285         parent::tearDown();
       
   286     }
       
   287 
       
   288     /**
       
   289      * Just test that the construct and setup are ok
       
   290      *
       
   291      * @return void
       
   292      */
       
   293     public function testInit()
       
   294     {
       
   295         $this->assertTrue(true);
       
   296         //echo $this->resGraph->serialise('turtle');
       
   297     }
       
   298 
       
   299     /**
       
   300      * Test merge modified merge TEXT into SOUND
       
   301      *
       
   302      * @return void
       
   303      */
       
   304     public function testModifiedSoundText() {
       
   305 
       
   306         $resGraph = $this->resGraph["SOUND_TEXT"];
       
   307 
       
   308         $providedCHO = $resGraph->get('edm:ProvidedCHO', '^rdf:type');
       
   309         $baseNode = $this->inputGraphes['SOUND']->get('edm:ProvidedCHO', '^rdf:type');
       
   310         $this->assertNotNull($providedCHO);
       
   311         $this->assertNotNull($baseNode);
       
   312 
       
   313         $outputValuesStr = [];
       
   314         foreach($providedCHO->all($resGraph->resource("http://purl.org/dc/terms/modified")) as $outputValue) {
       
   315             array_push($outputValuesStr, strval($outputValue));
       
   316         }
       
   317         $this->assertNotEmpty($outputValuesStr, "we must found some values to test http://purl.org/dc/terms/modified");
       
   318         foreach ($baseNode->all($this->inputGraphes['SOUND']->resource("http://purl.org/dc/terms/modified")) as $value) {
       
   319             $this->assertContains(strval($value), $outputValuesStr, "http://purl.org/dc/terms/modified not found in output graph");
       
   320         }
       
   321 
       
   322     }
       
   323 
       
   324     /**
       
   325      * Test one to one mapping
       
   326      *
       
   327      * @return void
       
   328      */
       
   329     public function testModifiedTextSound() {
       
   330 
       
   331         $resGraph = $this->resGraph["TEXT_SOUND"];
       
   332 
       
   333         $providedCHO = $resGraph->get('edm:ProvidedCHO', '^rdf:type');
       
   334         $baseNode = $this->inputGraphes['SOUND']->get('edm:ProvidedCHO', '^rdf:type');
       
   335         $this->assertNotNull($providedCHO);
       
   336         $this->assertNotNull($baseNode);
       
   337 
       
   338         $outputValuesStr = [];
       
   339         foreach($providedCHO->all($resGraph->resource("http://purl.org/dc/terms/modified")) as $outputValue) {
       
   340             array_push($outputValuesStr, strval($outputValue));
       
   341         }
       
   342         $this->assertNotEmpty($outputValuesStr, "we must found some values to test http://purl.org/dc/terms/modified");
       
   343         foreach ($baseNode->all($this->inputGraphes['SOUND']->resource("http://purl.org/dc/terms/modified")) as $value) {
       
   344             $this->assertContains(strval($value), $outputValuesStr, "http://purl.org/dc/terms/modified not found in output graph");
       
   345         }
       
   346 
       
   347     }
       
   348 
       
   349     /**
       
   350      * Test one to one mapping
       
   351      *
       
   352      * @return void
       
   353      */
       
   354     public function testSoundNoModifiedText() {
       
   355 
       
   356         $resGraph = $this->resGraph["SOUND_NO_MOD_TEXT"];
       
   357 
       
   358         $providedCHO = $resGraph->get('edm:ProvidedCHO', '^rdf:type');
       
   359         $baseNode = $this->inputGraphes['TEXT']->get('edm:ProvidedCHO', '^rdf:type');
       
   360         $this->assertNotNull($providedCHO);
       
   361         $this->assertNotNull($baseNode);
       
   362 
       
   363         $outputValuesStr = [];
       
   364         foreach($providedCHO->all($resGraph->resource("http://purl.org/dc/terms/modified")) as $outputValue) {
       
   365             array_push($outputValuesStr, strval($outputValue));
       
   366         }
       
   367         $this->assertNotEmpty($outputValuesStr, "we must found some values to test http://purl.org/dc/terms/modified");
       
   368         // must contain the TEXT modified value (since SOUND has none)
       
   369         foreach ($baseNode->all($this->inputGraphes['TEXT']->resource("http://purl.org/dc/terms/modified")) as $value) {
       
   370             $this->assertContains(strval($value), $outputValuesStr, "http://purl.org/dc/terms/modified not found in output graph");
       
   371         }
       
   372 
       
   373     }
       
   374 
       
   375 
       
   376     /**
       
   377      * Test one to one mapping
       
   378      *
       
   379      * @return void
       
   380      */
       
   381     public function testTextSoundNoModified() {
       
   382 
       
   383         $resGraph = $this->resGraph["TEXT_SOUND_NO_MOD"];
       
   384 
       
   385         $providedCHO = $resGraph->get('edm:ProvidedCHO', '^rdf:type');
       
   386         $baseNode = $this->inputGraphes['TEXT']->get('edm:ProvidedCHO', '^rdf:type');
       
   387         $this->assertNotNull($providedCHO);
       
   388         $this->assertNotNull($baseNode);
       
   389 
       
   390         $outputValuesStr = [];
       
   391         foreach($providedCHO->all($resGraph->resource("http://purl.org/dc/terms/modified")) as $outputValue) {
       
   392             array_push($outputValuesStr, strval($outputValue));
       
   393         }
       
   394         $this->assertNotEmpty($outputValuesStr, "we must found some values to test http://purl.org/dc/terms/modified");
       
   395         // must contain the TEXT modified value (since SOUND has none)
       
   396         foreach ($baseNode->all($this->inputGraphes['TEXT']->resource("http://purl.org/dc/terms/modified")) as $value) {
       
   397             $this->assertContains(strval($value), $outputValuesStr, "http://purl.org/dc/terms/modified not found in output graph");
       
   398         }
       
   399 
       
   400     }
       
   401 
       
   402 
       
   403     public function testRightsWebResource() {
       
   404         $properties = [
       
   405             "http://purl.org/dc/elements/1.1/rights",
       
   406             'http://purl.org/dc/terms/license',
       
   407             'http://purl.org/dc/terms/accessRights',
       
   408         ];
       
   409 
       
   410         $resGraph = $this->resGraph["SOUND_TEXT"];
       
   411         $webResourceList = $resGraph->all('edm:WebResource', '^rdf:type');
       
   412 
       
   413         //just check that they have all these resources.
       
   414         //TODO: check that the same rights are kept (difficult)
       
   415         foreach ($webResourceList as $webResource) {
       
   416             foreach ($properties as $prop) {
       
   417                 $outputValuesStr = [];
       
   418                 foreach($webResource->all($resGraph->resource($prop)) as $outputValue) {
       
   419                     array_push($outputValuesStr, strval($outputValue));
       
   420                 }
       
   421                 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop");
       
   422             }
       
   423         }
       
   424     }
       
   425 
       
   426     public function testRightDifferent() {
       
   427         $resGraph = $this->resGraph["SOUND_TEXT"];
       
   428 
       
   429         $aggregationRes = $resGraph->get('ore:Aggregation', '^rdf:type');
       
   430 
       
   431         $license = $aggregationRes->get('<http://www.europeana.eu/schemas/edm/rights>');
       
   432 
       
   433         $this->assertNotNull($license, "The licence must not be null");
       
   434         $this->assertInstanceOf("EasyRdf\Resource", $license, "Licence must be a resource");
       
   435         $this->assertEquals(config('corpusparole.corpus_doc_default_cc_rights'), $license->getUri(), "License must be default licence");
       
   436     }
       
   437 
       
   438     public function testRightSame() {
       
   439         $resGraph = $this->resGraph["SOUND_NO_MOD_TEXT"];
       
   440 
       
   441         $aggregationRes = $resGraph->get('ore:Aggregation', '^rdf:type');
       
   442 
       
   443         $license = $aggregationRes->get('<http://www.europeana.eu/schemas/edm/rights>');
       
   444 
       
   445         $this->assertNotNull($license, "The licence must not be null");
       
   446         $this->assertInstanceOf("EasyRdf\Resource", $license, "Licence must be a resource");
       
   447         $this->assertEquals('http://creativecommons.org/licenses/by-nc-sa/4.0/', $license->getUri(), "License must be default licence");
       
   448     }
       
   449 
       
   450 
       
   451 
       
   452 }