server/src/tests/libraries/Mappers/CocoonSoundRdfMapperTest.php
changeset 18 f2a40bbc27f6
child 21 01e7e6a17317
equal deleted inserted replaced
17:ac3dc090e987 18:f2a40bbc27f6
       
     1 <?php
       
     2 
       
     3 use CorpusParole\Libraries\Mappers\CocoonSoundRdfMapper;
       
     4 use CorpusParole\Libraries\CocoonUtils;
       
     5 
       
     6 use EasyRdf\Graph;
       
     7 use EasyRdf\Resource;
       
     8 use EasyRdf\Literal;
       
     9 
       
    10 use Illuminate\Foundation\Testing\WithoutMiddleware;
       
    11 use Illuminate\Foundation\Testing\DatabaseMigrations;
       
    12 use Illuminate\Foundation\Testing\DatabaseTransactions;
       
    13 
       
    14 class CocoonSoundRdfMapperTest extends TestCase
       
    15 {
       
    16 
       
    17     const TEST_INPUT_DOCS = [
       
    18         'BASE' => <<<EOT
       
    19         @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
       
    20         @prefix owl: <http://www.w3.org/2002/07/owl#> .
       
    21         @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
       
    22         @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
       
    23         @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
       
    24         @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
       
    25         @prefix v: <http://rdf.data-vocabulary.org/#> .
       
    26             <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019> a <http://crdo.risc.cnrs.fr/schemas/Resource> ;
       
    27             <http://purl.org/dc/elements/1.1/description> "Extrait du corpus d'Orléans, réalisé dans le cadre de l'Enquête SocioLinguistique à Orléans à la fin des années 1960."@fr ;
       
    28             <http://purl.org/dc/elements/1.1/type> <http://purl.org/dc/dcmitype/Sound> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
       
    29             <http://purl.org/dc/elements/1.1/subject> <http://lexvo.org/id/iso639-3/fra> , "text_and_corpus_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb135052099> , <http://ark.bnf.fr/ark:/12148/cb11943508j> , <http://ark.bnf.fr/ark:/12148/cb11934124q> , <http://ark.bnf.fr/ark:/12148/cb11931498c> , <http://ark.bnf.fr/ark:/12148/cb11935508t> , <http://ark.bnf.fr/ark:/12148/cb11934132b> , <http://ark.bnf.fr/ark:/12148/cb11939893p> , <http://ark.bnf.fr/ark:/12148/cb11933091b> ;
       
    30             <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
       
    31             <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/181558906> ;
       
    32             <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/181558906> ;
       
    33             <http://purl.org/dc/elements/1.1/rights> "Copyright (c) 2012 Université d'Orléans/LLL" ;
       
    34             <http://purl.org/dc/elements/1.1/title> "ESLO1: entretien 019"@fr ;
       
    35             <http://purl.org/dc/terms/alternative> "ESLO1: entretien 019 alt"@fr ;
       
    36             <http://purl.org/dc/terms/isFormatOf> <http://cocoon.huma-num.fr/data/eslo/ESLO1_ENT_019_22km.wav> , <http://cocoon.huma-num.fr/data/eslo/ESLO1_ENT_019.mp3> ;
       
    37             <http://purl.org/dc/terms/accessRights> " Freely available for non-commercial use" ;
       
    38             <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
    39             <http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1> ;
       
    40             <http://purl.org/dc/terms/extent> "PT0H47M16S" ;
       
    41             <http://purl.org/dc/terms/created> "1969-04-11"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    42             <http://purl.org/dc/terms/spatial> "FR"^^<http://purl.org/dc/terms/ISO3166> , <http://vocab.getty.edu/tgn/7008337> , "France, Centre, Loiret, Orléans"@fr ;
       
    43             <http://crdo.risc.cnrs.fr/schemas/master> <http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav> ;
       
    44             <http://purl.org/dc/terms/available> "2014-11-06"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    45             <http://purl.org/dc/terms/issued> "2014-12-05T15:00:19+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    46             <http://purl.org/dc/terms/modified> "2014-12-05T15:00:19+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    47             <http://www.language-archives.org/OLAC/1.1/speaker> "JK" , "UG393" ;
       
    48             <http://purl.org/dc/elements/1.1/source> <http://archivesetmanuscrits.bnf.fr/ead.html?id=FRBNFEAD000095934&c=FRBNFEAD000095934_a19844296> ;
       
    49             <http://www.w3.org/2003/01/geo/wgs84_pos#long> "1.90"^^xsd:float ;
       
    50             <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "47.90"^^xsd:float ;
       
    51             <http://purl.org/dc/terms/tableOfContents> "01 née; famille a toujours habité Orléans03 oui, on y a des amis, relations04 oui, certainementT1 centralisait comptabilité dans une industrieT2 RR passer des écritures, caisse; horaires avant et après loi de 1936T3 aimait travail, rien ne lui déplaisaitT4 n'a jamais pensé à çaT5 actuellement on est forcée quelquefois - assurance sociale - retraite appréciable; autre chose avec enfantL1 concerts, théâtre, réunions, etc...:préfère s'occuperL2 messe, puis a passé la journée avec une amieL3 (quand elle travaillait) au bord de la mer ou voyages organisésE1 n'en sait rienE2 lui semble que ça aide le françaisE3 peut-être chimie, physiqueE4 intelligence, travail, familleE5 dépend de leurs capacitésE6 non : dépend de la vie de l'enfant plus tardP1 oui, à part loyers chersP4 ne comprend pas motifs des étudiants; très calme à OrléansP9 moins qu'avant 1940P10 RR bourgeois = gros rentiers, femmes d'officierss, gros industriels; chaque groupe se recevait mutuellement, formait un clanQ. Orléans une ville renfermée? oui : orléanais assez distant, peut-être moins maintenantP6 il faut avoir la moitié des votesP7 des candidats se retirentP8 droite gaulliste, réservée; gauche avancéeP5 pas grand-chose - attachés à leurs partisP11 oui, maintenant, par l'éducation; famille moins importanteP12 à diminuer : les gens travaillent beaucoup plus et l'argent a changé de mainsOmelette (je casse mes oeufs...)Questionnaire sociolinguistique"@fr ;
       
    52             <http://purl.org/dc/terms/isRequiredBy> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019_C> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019_A> ;
       
    53             <http://www.language-archives.org/OLAC/1.1/editor> <http://viaf.org/viaf/39685504> , <http://viaf.org/viaf/200058210> ;
       
    54             <http://purl.org/dc/terms/abstract> " Identifiant du témoin : UG 393 Femme, 72 ans (né en 1897, à Orléans ) ; comptable en retraite Enregistré par Jack Kay, le 11 avril 1969, au domicile du témoin. Questionnaires enregistrés : questionnaire sociolinguistique; questionnaire ouvert(questions 01 ; 03-04 ; T1-T5 ; L1-L3 ; E1-E6 ; P1 ; P4 ; P9-P10 ; P6-P8 ; P5 ; P11-P12 ; omelette). Classe politique du témoin : Centre Remarques sur le témoignage : réponses concises. Intérêt pédagogique : conditions de travail avant la guerre de 1940 ; classes sociales. Acoustique : bonne qualité d'enregistrement."@fr ;
       
    55             <http://www.language-archives.org/OLAC/1.1/researcher> "Kay, Jack" ;
       
    56             <http://purl.org/dc/elements/1.1/relation> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENTCONT_233> ;
       
    57             <http://purl.org/dc/terms/medium> "1 bande magnétique audio"@fr ;
       
    58             <http://purl.org/dc/terms/bibliographicCitation> "A.-M. VURPAS (1988), Autrefois dans les monts du Beaujolais, Action graphique.";
       
    59             <http://purl.org/dc/elements/1.1/identifier> "Cote producteur: 001_3"@fr ;
       
    60             <http://purl.org/dc/elements/1.1/reference> <http://panini.u-paris10.fr> ;
       
    61             <http://purl.org/dc/elements/1.1/coverage> "Quartier concerné : 3e"@fr ;
       
    62             <http://purl.org/dc/elements/1.1/creator> "Blanc, Michel" , "Biggs, Patricia" .
       
    63 EOT
       
    64         ,
       
    65         'NO-FORMAT' => <<<EOT
       
    66         @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
       
    67         @prefix owl: <http://www.w3.org/2002/07/owl#> .
       
    68         @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
       
    69         @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
       
    70         @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
       
    71         @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
       
    72         @prefix v: <http://rdf.data-vocabulary.org/#> .
       
    73             <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019> a <http://crdo.risc.cnrs.fr/schemas/Resource> ;
       
    74             <http://purl.org/dc/elements/1.1/description> "Extrait du corpus d'Orléans, réalisé dans le cadre de l'Enquête SocioLinguistique à Orléans à la fin des années 1960."@fr ;
       
    75             <http://purl.org/dc/elements/1.1/type> <http://purl.org/dc/dcmitype/Sound> , "primary_text"^^<http://www.language-archives.org/OLAC/1.1/linguistic-type> , "dialogue"^^<http://www.language-archives.org/OLAC/1.1/discourse-type> ;
       
    76             <http://purl.org/dc/elements/1.1/subject> <http://lexvo.org/id/iso639-3/fra> , "text_and_corpus_linguistics"^^<http://www.language-archives.org/OLAC/1.1/linguistic-field> , <http://ark.bnf.fr/ark:/12148/cb135052099> , <http://ark.bnf.fr/ark:/12148/cb11943508j> , <http://ark.bnf.fr/ark:/12148/cb11934124q> , <http://ark.bnf.fr/ark:/12148/cb11931498c> , <http://ark.bnf.fr/ark:/12148/cb11935508t> , <http://ark.bnf.fr/ark:/12148/cb11934132b> , <http://ark.bnf.fr/ark:/12148/cb11939893p> , <http://ark.bnf.fr/ark:/12148/cb11933091b> ;
       
    77             <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
       
    78             <http://www.language-archives.org/OLAC/1.1/depositor> <http://viaf.org/viaf/181558906> ;
       
    79             <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/181558906> ;
       
    80             <http://purl.org/dc/elements/1.1/rights> "Copyright (c) 2012 Université d'Orléans/LLL" ;
       
    81             <http://purl.org/dc/elements/1.1/title> "ESLO1: entretien 019"@fr ;
       
    82             <http://purl.org/dc/terms/alternative> "ESLO1: entretien 019 alt"@fr ;
       
    83             <http://purl.org/dc/terms/isFormatOf> <http://cocoon.huma-num.fr/data/eslo/ESLO1_ENT_019_22km.wav> , <http://cocoon.huma-num.fr/data/eslo/ESLO1_ENT_019.mp3> ;
       
    84             <http://purl.org/dc/terms/accessRights> " Freely available for non-commercial use" ;
       
    85             <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
    86             <http://purl.org/dc/terms/isPartOf> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1> ;
       
    87             <http://purl.org/dc/terms/extent> "PT0H47M16S" ;
       
    88             <http://purl.org/dc/terms/created> "1969-04-11"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    89             <http://purl.org/dc/terms/spatial> "FR"^^<http://purl.org/dc/terms/ISO3166> , <http://vocab.getty.edu/tgn/7008337> , "France, Centre, Loiret, Orléans"@fr ;
       
    90             <http://crdo.risc.cnrs.fr/schemas/master> <http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav> ;
       
    91             <http://purl.org/dc/terms/available> "2014-11-06"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    92             <http://purl.org/dc/terms/issued> "2014-12-05T15:00:19+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    93             <http://purl.org/dc/terms/modified> "2014-12-05T15:00:19+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
    94             <http://www.language-archives.org/OLAC/1.1/speaker> "JK" , "UG393" ;
       
    95             <http://purl.org/dc/elements/1.1/source> <http://archivesetmanuscrits.bnf.fr/ead.html?id=FRBNFEAD000095934&c=FRBNFEAD000095934_a19844296> ;
       
    96             <http://www.w3.org/2003/01/geo/wgs84_pos#long> "1.90"^^xsd:float ;
       
    97             <http://www.w3.org/2003/01/geo/wgs84_pos#lat> "47.90"^^xsd:float ;
       
    98             <http://purl.org/dc/terms/tableOfContents> "01 née; famille a toujours habité Orléans03 oui, on y a des amis, relations04 oui, certainementT1 centralisait comptabilité dans une industrieT2 RR passer des écritures, caisse; horaires avant et après loi de 1936T3 aimait travail, rien ne lui déplaisaitT4 n'a jamais pensé à çaT5 actuellement on est forcée quelquefois - assurance sociale - retraite appréciable; autre chose avec enfantL1 concerts, théâtre, réunions, etc...:préfère s'occuperL2 messe, puis a passé la journée avec une amieL3 (quand elle travaillait) au bord de la mer ou voyages organisésE1 n'en sait rienE2 lui semble que ça aide le françaisE3 peut-être chimie, physiqueE4 intelligence, travail, familleE5 dépend de leurs capacitésE6 non : dépend de la vie de l'enfant plus tardP1 oui, à part loyers chersP4 ne comprend pas motifs des étudiants; très calme à OrléansP9 moins qu'avant 1940P10 RR bourgeois = gros rentiers, femmes d'officierss, gros industriels; chaque groupe se recevait mutuellement, formait un clanQ. Orléans une ville renfermée? oui : orléanais assez distant, peut-être moins maintenantP6 il faut avoir la moitié des votesP7 des candidats se retirentP8 droite gaulliste, réservée; gauche avancéeP5 pas grand-chose - attachés à leurs partisP11 oui, maintenant, par l'éducation; famille moins importanteP12 à diminuer : les gens travaillent beaucoup plus et l'argent a changé de mainsOmelette (je casse mes oeufs...)Questionnaire sociolinguistique"@fr ;
       
    99             <http://purl.org/dc/terms/isRequiredBy> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019_C> , <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019_A> ;
       
   100             <http://www.language-archives.org/OLAC/1.1/editor> <http://viaf.org/viaf/39685504> , <http://viaf.org/viaf/200058210> ;
       
   101             <http://purl.org/dc/terms/abstract> " Identifiant du témoin : UG 393 Femme, 72 ans (né en 1897, à Orléans ) ; comptable en retraite Enregistré par Jack Kay, le 11 avril 1969, au domicile du témoin. Questionnaires enregistrés : questionnaire sociolinguistique; questionnaire ouvert(questions 01 ; 03-04 ; T1-T5 ; L1-L3 ; E1-E6 ; P1 ; P4 ; P9-P10 ; P6-P8 ; P5 ; P11-P12 ; omelette). Classe politique du témoin : Centre Remarques sur le témoignage : réponses concises. Intérêt pédagogique : conditions de travail avant la guerre de 1940 ; classes sociales. Acoustique : bonne qualité d'enregistrement."@fr ;
       
   102             <http://www.language-archives.org/OLAC/1.1/researcher> "Kay, Jack" ;
       
   103             <http://purl.org/dc/elements/1.1/relation> <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENTCONT_233> ;
       
   104             <http://purl.org/dc/terms/medium> "1 bande magnétique audio"@fr ;
       
   105             <http://purl.org/dc/terms/bibliographicCitation> "A.-M. VURPAS (1988), Autrefois dans les monts du Beaujolais, Action graphique.";
       
   106             <http://purl.org/dc/elements/1.1/identifier> "Cote producteur: 001_3"@fr ;
       
   107             <http://purl.org/dc/elements/1.1/reference> <http://panini.u-paris10.fr> ;
       
   108             <http://purl.org/dc/elements/1.1/creator> "Blanc, Michel" , "Biggs, Patricia" .
       
   109 
       
   110 EOT
       
   111     ];
       
   112 
       
   113     const TEST_INPUT_ID = "crdo-ESLO1_ENT_019";
       
   114     const TEST_GRAPH_URI = "http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ESLO1_ENT_019";
       
   115     const TEST_CHO_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019";
       
   116 
       
   117 
       
   118     private $inputGraphes = [];
       
   119     private $resGraphes = [];
       
   120     private $mappers = [];
       
   121 
       
   122     function __construct(string $name = null) {
       
   123         parent::__construct($name);
       
   124     }
       
   125 
       
   126     public function setUp() {
       
   127         parent::setUp();
       
   128 
       
   129         foreach(CocoonSoundRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) {
       
   130             $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019", $inputDoc);
       
   131             $this->mappers[$key] = new CocoonSoundRdfMapper($this->inputGraphes[$key]);
       
   132             $this->mappers[$key]->mapGraph();
       
   133             $this->resGraphes[$key] = $this->mappers[$key]->getOutputGraphes()[$this->inputGraphes[$key]->getUri()];
       
   134         }
       
   135     }
       
   136 
       
   137     public function tearDown() {
       
   138         parent::tearDown();
       
   139     }
       
   140 
       
   141     /**
       
   142      * Just test that the construct and setup are ok
       
   143      *
       
   144      * @return void
       
   145      */
       
   146     public function testInit()
       
   147     {
       
   148         $this->assertTrue(true);
       
   149     }
       
   150 
       
   151     /**
       
   152      * Test that the returned graph has the same uri that the original.
       
   153      *
       
   154      * @return void
       
   155      */
       
   156     public function testUri() {
       
   157 
       
   158          echo $this->resGraphes['BASE']->serialise('turtle');
       
   159          //echo var_export($this->resGraphes['BASE']->toRdfPhp());
       
   160 
       
   161          $this->assertNotNull($this->resGraphes['BASE']);
       
   162          $this->assertEquals(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, $this->resGraphes['BASE']->getUri(), "URIS must be translated");
       
   163      }
       
   164 
       
   165     /**
       
   166       * Test that the return graph has one ore:Aggregation resource
       
   167       *
       
   168       * @return void
       
   169       */
       
   170     public function testAggregationResource() {
       
   171 
       
   172          $resources = $this->resGraphes['BASE']->allOfType('ore:Aggregation');
       
   173 
       
   174          $this->assertCount(1, $resources, "Must found only one resources of type ore:Aggregation");
       
   175          $this->assertEquals(CocoonSoundRdfMapperTest::TEST_GRAPH_URI,$resources[0]);
       
   176      }
       
   177 
       
   178     /**
       
   179       * test that there one (and only one) edm:dateProvider and edm:provider property
       
   180       *
       
   181       * @return void
       
   182       */
       
   183     public function testProviders() {
       
   184 
       
   185          $providers = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI,'edm:provider');
       
   186 
       
   187          $this->assertCount(1,$providers, "one and only one edm provider");
       
   188          $this->assertTrue($providers[0] instanceof Literal);
       
   189          $this->assertEquals('Corpus de la Parole', $providers[0]->getValue(), 'provider must be Corpus de la Parole');
       
   190          $this->assertEquals('fr', $providers[0]->getLang(), 'provider must be in french');
       
   191 
       
   192          $dataProviders = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI,'edm:dataProvider');
       
   193 
       
   194          $this->assertCount(1,$dataProviders, "one and only one edm data provider");
       
   195          //TODO: to change after viaf resolution
       
   196          $this->assertTrue($dataProviders[0] instanceof Resource);
       
   197          $this->assertEquals('http://viaf.org/viaf/181558906', $dataProviders[0]->getUri(), 'dataProvider uri must be http://viaf.org/viaf/181558906');
       
   198     }
       
   199 
       
   200 
       
   201     /**
       
   202      * test isShownAt and isShownBy
       
   203      *
       
   204      * @return void
       
   205      */
       
   206     public function testIsShown() {
       
   207 
       
   208         $isShownAts = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, 'edm:isShownAt');
       
   209 
       
   210         $this->assertCount(1, $isShownAts, "One edm:isShownAt");
       
   211         $this->assertInstanceOf("EasyRdf\Resource", $isShownAts[0]);
       
   212         $this->assertEquals("http://cocoon.huma-num.fr/exist/crdo/meta/crdo-ESLO1_ENT_019", $isShownAts[0]);
       
   213 
       
   214         $isShownBys = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, 'edm:isShownBy');
       
   215 
       
   216         $this->assertCount(1, $isShownBys, "One edm:isShownBy");
       
   217         $this->assertInstanceOf("EasyRdf\Resource", $isShownBys[0]);
       
   218         $this->assertEquals("http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav", $isShownBys[0]);
       
   219 
       
   220     }
       
   221 
       
   222     /**
       
   223      * test rights
       
   224      *
       
   225      * @return void
       
   226      */
       
   227     public function testRights() {
       
   228         $rightsNodes = $this->resGraphes['BASE']->all(CocoonSoundRdfMapperTest::TEST_GRAPH_URI, 'edm:rights');
       
   229 
       
   230         $this->assertCount(1, $rightsNodes, "One edm:right");
       
   231 
       
   232         $rights = $rightsNodes[0];
       
   233 
       
   234         $this->assertTrue($rights instanceof Resource);
       
   235 
       
   236         $this->assertEquals("http://creativecommons.org/licenses/by-nc-sa/4.0/", $rights->getUri(), "right must be CC-BY-NC");
       
   237     }
       
   238 
       
   239     /**
       
   240      * Test that the return graph has one ore:Aggregation resource
       
   241      *
       
   242      * @return void
       
   243      */
       
   244     public function testProvidedCHO() {
       
   245 
       
   246          $resources = $this->resGraphes['BASE']->allOfType('edm:ProvidedCHO');
       
   247 
       
   248          $this->assertCount(1, $resources, "Must found only one resources of type edm:aggregatedCHO");
       
   249          $this->assertEquals(CocoonSoundRdfMapperTest::TEST_CHO_URI,$resources[0]);
       
   250      }
       
   251 
       
   252     /**
       
   253      * Test one to one mapping
       
   254      *
       
   255      * @return void
       
   256      */
       
   257     public function testOneToOneProvidedCHOIdentity() {
       
   258 
       
   259         $properties = [
       
   260             'http://purl.org/dc/terms/tableOfContents',
       
   261             'http://purl.org/dc/elements/1.1/description',
       
   262             'http://purl.org/dc/elements/1.1/language',
       
   263             'http://purl.org/dc/elements/1.1/publisher',
       
   264             'http://purl.org/dc/elements/1.1/rights',
       
   265             'http://purl.org/dc/terms/license',
       
   266             'http://purl.org/dc/elements/1.1/subject',
       
   267             'http://purl.org/dc/elements/1.1/title',
       
   268             'http://purl.org/dc/terms/available',
       
   269             'http://purl.org/dc/terms/created',
       
   270             'http://purl.org/dc/terms/issued',
       
   271             'http://purl.org/dc/terms/extent',
       
   272             'http://purl.org/dc/elements/1.1/type',
       
   273             'http://purl.org/dc/elements/1.1/language',
       
   274             'http://purl.org/dc/terms/medium',
       
   275             'http://purl.org/dc/terms/isPartOf',
       
   276             'http://purl.org/dc/elements/1.1/source',
       
   277             'http://purl.org/dc/terms/alternative',
       
   278             'http://purl.org/dc/terms/modified',
       
   279             'http://purl.org/dc/terms/bibliographicCitation',
       
   280             'http://purl.org/dc/elements/1.1/identifier',
       
   281             'http://purl.org/dc/terms/references',
       
   282             'http://purl.org/dc/elements/1.1/coverage',
       
   283             'http://purl.org/dc/elements/1.1/relation',
       
   284             'http://purl.org/dc/elements/1.1/creator',
       
   285         ];
       
   286 
       
   287         $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type');
       
   288         $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   289 
       
   290         $this->assertNotNull($providedCHO);
       
   291         $this->assertNotNull($sourceNode);
       
   292 
       
   293         foreach ($properties as $prop) {
       
   294             $outputValuesStr = [];
       
   295             foreach($providedCHO->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) {
       
   296                 array_push($outputValuesStr, strval($outputValue));
       
   297             }
       
   298             $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop");
       
   299             foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) {
       
   300                 $this->assertContains(strval($value), $outputValuesStr, "$prop not found in output graph");
       
   301             }
       
   302         }
       
   303 
       
   304     }
       
   305 
       
   306     /**
       
   307     * Test one to one mapping spatial info
       
   308     *
       
   309     * @return void
       
   310     */
       
   311     public function testOneToOneProvidedCHOSpatial() {
       
   312         $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type');
       
   313         $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   314 
       
   315         $this->assertNotNull($providedCHO);
       
   316         $this->assertNotNull($sourceNode);
       
   317 
       
   318         $spatials = $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/terms/spatial'));
       
   319 
       
   320         $this->assertCount(1, $spatials, "Must have only one spatial node");
       
   321         $spatial = $spatials[0];
       
   322         $this->assertTrue($spatial->isBNode(),"spatial node must be blank");
       
   323         $this->assertEquals("edm:Place", $spatial->type(), "spatial node type must be edm:Place");
       
   324 
       
   325         $lats = $spatial->all('geo:lat');
       
   326         $this->assertCount(1, $lats, "One latitude");
       
   327         $this->assertInstanceOf("EasyRdf\Literal", $lats[0], "Latitude must be a litteral");
       
   328         $this->assertEquals(Literal::create("47.90", null, 'xsd:float'), $lats[0], "lat must be '47.90'^^xsd:float");
       
   329 
       
   330         $longs = $spatial->all('geo:long');
       
   331         $this->assertCount(1, $longs, "One longitude");
       
   332         $this->assertInstanceOf("EasyRdf\Literal", $longs[0], "Longitude must be a litteral");
       
   333         $this->assertEquals(Literal::create("1.90", null, 'xsd:float'), $longs[0], "long must be '1.90'^^xsd:float");
       
   334 
       
   335         $notes = $spatial->all('skos:note');
       
   336         $this->assertCount(2, $notes, "2 notes");
       
   337         $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $notes, "Notes mus be only literals");
       
   338         $this->assertEquals(Literal::create("FR", null, "dc:ISO3166"), $notes[0], "notes contains 'FR'^^dc:ISO3166");
       
   339         $this->assertEquals(Literal::create("France, Centre, Loiret, Orléans", "fr", null), $notes[1], "notes contains 'France, Centre, Loiret, Orléans'@fr");
       
   340 
       
   341         $sameas = $spatial->all('owl:sameAs');
       
   342         $this->assertCount(1, $sameas, "1 same as");
       
   343         $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources");
       
   344         $this->assertEquals('http://vocab.getty.edu/tgn/7008337', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008337");
       
   345     }
       
   346 
       
   347     /**
       
   348      * Test one to one mapping trim values
       
   349      *
       
   350      * @return void
       
   351      */
       
   352     public function testOneToOneProvidedCHOTrim() {
       
   353 
       
   354         $properties = [
       
   355             'http://purl.org/dc/terms/accessRights',
       
   356         ];
       
   357 
       
   358         $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type');
       
   359         $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   360 
       
   361         $this->assertNotNull($providedCHO);
       
   362         $this->assertNotNull($sourceNode);
       
   363 
       
   364         foreach ($properties as $prop) {
       
   365             $outputValuesStr = [];
       
   366             foreach($providedCHO->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) {
       
   367                 array_push($outputValuesStr, strval($outputValue));
       
   368             }
       
   369             $this->assertNotEmpty($outputValuesStr, 'we must found some values to test');
       
   370             foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) {
       
   371                 $this->assertContains(trim(strval($value)), $outputValuesStr, "$prop not found in output graph");
       
   372             }
       
   373         }
       
   374     }
       
   375 
       
   376     /**
       
   377      * Test one to one mapping trim values
       
   378      *
       
   379      * @return void
       
   380      */
       
   381     public function testOneToOneProvidedCHOReference() {
       
   382 
       
   383         $providedCHO = $this->resGraphes['NO-FORMAT']->get('edm:ProvidedCHO', '^rdf:type');
       
   384         $sourceNode = $this->inputGraphes['NO-FORMAT']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type');
       
   385 
       
   386         $this->assertNotNull($providedCHO);
       
   387         $this->assertNotNull($sourceNode);
       
   388 
       
   389         $outputValuesStr = [];
       
   390         foreach($providedCHO->all($this->resGraphes['NO-FORMAT']->resource('http://purl.org/dc/terms/references')) as $outputValue) {
       
   391             array_push($outputValuesStr, strval($outputValue));
       
   392         }
       
   393         $this->assertNotEmpty($outputValuesStr, 'we must found some values to test for http://purl.org/dc/elements/1.1/reference');
       
   394         foreach ($sourceNode->all($this->inputGraphes['NO-FORMAT']->resource('http://purl.org/dc/elements/1.1/reference')) as $value) {
       
   395             $this->assertContains(strval($value), $outputValuesStr, "http://purl.org/dc/terms/references not found in output graph");
       
   396         }
       
   397     }
       
   398 
       
   399 
       
   400     /**
       
   401      * Test that the web resources
       
   402      *
       
   403      * @return void
       
   404      */
       
   405     public function testWebResources() {
       
   406 
       
   407         $resources = $this->resGraphes['BASE']->allOfType('edm:WebResources');
       
   408 
       
   409         $this->assertCount(3, $resources, "Must found three webresources");
       
   410 
       
   411         $aggregation = $this->resGraphes['BASE']->resource(CocoonSoundRdfMapperTest::TEST_GRAPH_URI);
       
   412 
       
   413         foreach ($resources as $wres) {
       
   414             $mimetypes = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/format'));
       
   415             $this->assertCount(1, $mimetypes, "Must find one mimetype.");
       
   416             $mimetype = $mimetypes[0];
       
   417             $this->assertInstanceOf("EasyRdf\Literal", $mimetype, "mimetype must be literal");
       
   418             $this->assertEquals("dc:IMT",$mimetype->getDatatype());
       
   419 
       
   420             $extends = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/terms/extent'));
       
   421             $this->assertCount(1, $extends, "Must find one extent.");
       
   422             $extent = $extends[0];
       
   423             $this->assertInstanceOf("EasyRdf\Literal", $extent, "extent must be literal");
       
   424             $this->assertStringStartsWith("PT", $extent->getValue(), "value mus start with PT");
       
   425 
       
   426             if($wres->hasProperty('edm:isDerivativeOf')) {
       
   427                 $derivative = $wres->get('edm:isDerivativeOf');
       
   428                 $this->assertInstanceOf("EasyRdf\Resource", $derivative, "Derivative must be a resource");
       
   429                 $this->assertEquals("http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav", $derivative->getUri(), "derivative uri must be http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav");
       
   430                 $this->assertTrue($aggregation->hasProperty('edm:hasView', $wres));
       
   431             }
       
   432             else {
       
   433                 $this->assertTrue($aggregation->hasProperty('edm:isShownBy', $wres));
       
   434             }
       
   435 
       
   436         }
       
   437     }
       
   438 
       
   439     /**
       
   440      * Test that the web resources
       
   441      *
       
   442      * @return void
       
   443      */
       
   444     public function testWebResourcesDate() {
       
   445 
       
   446         $resources = $this->resGraphes['BASE']->allOfType('edm:WebResources');
       
   447 
       
   448         foreach ($resources as $wres) {
       
   449             $this->assertFalse($wres->hasProperty("http://purl.org/dc/terms/available"),"web resource must not have http://purl.org/dc/terms/available");
       
   450             $this->assertFalse($wres->hasProperty("http://purl.org/dc/terms/modified"),"web resource must not have http://purl.org/dc/terms/modified");
       
   451             $this->assertTrue($wres->hasProperty("http://purl.org/dc/terms/issued"), "Must have http://purl.org/dc/terms/issued");
       
   452             $this->assertTrue($wres->hasProperty("http://purl.org/dc/terms/created"), "Must have http://purl.org/dc/terms/created");
       
   453 
       
   454             $issued = $wres->getLiteral('dc:issued');
       
   455             //<http://purl.org/dc/terms/issued> "2014-12-05T15:00:19+01:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
   456             $this->assertInstanceOf('EasyRdf\Literal', $issued, "issued value must be a literal");
       
   457             $this->assertEquals('http://purl.org/dc/terms/W3CDTF', $issued->getDatatypeUri(), "issued datatype uri must be a http://purl.org/dc/terms/W3CDTF");
       
   458             $this->assertEquals('2014-12-05T15:00:19+01:00', $issued->getValue(), "Value must be 2014-12-05T15:00:19+01:00");
       
   459 
       
   460             $created = $wres->getLiteral('dc:created');
       
   461             //<http://purl.org/dc/terms/created> "1969-04-11"^^<http://purl.org/dc/terms/W3CDTF> ;
       
   462             $this->assertInstanceOf('EasyRdf\Literal', $created, "created value must be a literal");
       
   463             $this->assertEquals('http://purl.org/dc/terms/W3CDTF', $created->getDatatypeUri(), "created datatype uri must be a http://purl.org/dc/terms/W3CDTF");
       
   464             $this->assertEquals('1969-04-11', $created->getValue(), "Value must be 1969-04-11");
       
   465 
       
   466         }
       
   467 
       
   468     }
       
   469 
       
   470 
       
   471     /**
       
   472      * Test collection graph creation
       
   473      * @return void
       
   474      */
       
   475     public function testCollectionGraph() {
       
   476         $outputs = $this->mappers['BASE']->getOutputGraphes();
       
   477         $this->assertCount(3, $outputs, "Must have 3 graphes as output");
       
   478         foreach($outputs as $url => $outputGraph) {
       
   479             if($outputGraph->getUri() == 'http://purl.org/poi/corpusdelaparole.huma-num.fr/crdo-ESLO1_ENT_019') {
       
   480                 continue;
       
   481             }
       
   482             $this->assertContains($outputGraph->getUri(), ['http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_LANGUESDEFRANCE', 'http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-COLLECTION_ESLO1']);
       
   483             $this->assertEquals($outputGraph->resource($outputGraph->getUri())->type(), 'edm:Collection');
       
   484         }
       
   485     }
       
   486 
       
   487 }