|
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>, <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_010> ; |
|
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_CHO_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019"; |
|
115 |
|
116 |
|
117 private $inputGraphes = []; |
|
118 private $resGraphes = []; |
|
119 private $mappers = []; |
|
120 |
|
121 function __construct(string $name = null) { |
|
122 parent::__construct($name); |
|
123 } |
|
124 |
|
125 public function setUp() { |
|
126 parent::setUp(); |
|
127 |
|
128 $this->testGraphUri = config('corpusparole.corpus_doc_id_base_uri').CocoonSoundRdfMapperTest::TEST_INPUT_ID; |
|
129 |
|
130 foreach(CocoonSoundRdfMapperTest::TEST_INPUT_DOCS as $key => $inputDoc) { |
|
131 $this->inputGraphes[$key] = new Graph("http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019", $inputDoc); |
|
132 $this->mappers[$key] = new CocoonSoundRdfMapper($this->inputGraphes[$key]); |
|
133 $this->mappers[$key]->mapGraph(); |
|
134 $this->resGraphes[$key] = $this->mappers[$key]->getOutputGraphes()[$this->inputGraphes[$key]->getUri()]; |
|
135 } |
|
136 } |
|
137 |
|
138 public function tearDown() { |
|
139 parent::tearDown(); |
|
140 } |
|
141 |
|
142 /** |
|
143 * Just test that the construct and setup are ok |
|
144 * |
|
145 * @return void |
|
146 */ |
|
147 public function testInit() |
|
148 { |
|
149 $this->assertTrue(true); |
|
150 } |
|
151 |
|
152 /** |
|
153 * Test that the returned graph has the same uri that the original. |
|
154 * |
|
155 * @return void |
|
156 */ |
|
157 public function testUri() { |
|
158 |
|
159 //echo $this->resGraphes['BASE']->serialise('turtle'); |
|
160 //echo var_export($this->resGraphes['BASE']->toRdfPhp()); |
|
161 |
|
162 $this->assertNotNull($this->resGraphes['BASE']); |
|
163 $this->assertEquals($this->testGraphUri, $this->resGraphes['BASE']->getUri(), "URIS must be translated"); |
|
164 } |
|
165 |
|
166 /** |
|
167 * Test that the return graph has one ore:Aggregation resource |
|
168 * |
|
169 * @return void |
|
170 */ |
|
171 public function testAggregationResource() { |
|
172 |
|
173 $resources = $this->resGraphes['BASE']->allOfType('ore:Aggregation'); |
|
174 |
|
175 $this->assertCount(1, $resources, "Must found only one resources of type ore:Aggregation"); |
|
176 $this->assertEquals($this->testGraphUri,$resources[0]); |
|
177 } |
|
178 |
|
179 /** |
|
180 * test that there one (and only one) edm:dateProvider and edm:provider property |
|
181 * |
|
182 * @return void |
|
183 */ |
|
184 public function testProviders() { |
|
185 |
|
186 $providers = $this->resGraphes['BASE']->all($this->testGraphUri,'edm:provider'); |
|
187 |
|
188 $this->assertCount(1,$providers, "one and only one edm provider"); |
|
189 $this->assertTrue($providers[0] instanceof Literal); |
|
190 $this->assertEquals('Corpus de la Parole', $providers[0]->getValue(), 'provider must be Corpus de la Parole'); |
|
191 $this->assertEquals('fr', $providers[0]->getLang(), 'provider must be in french'); |
|
192 |
|
193 $dataProviders = $this->resGraphes['BASE']->all($this->testGraphUri,'edm:dataProvider'); |
|
194 |
|
195 $this->assertCount(1,$dataProviders, "one and only one edm data provider"); |
|
196 //TODO: to change after viaf resolution |
|
197 $this->assertTrue($dataProviders[0] instanceof Resource); |
|
198 $this->assertEquals('http://viaf.org/viaf/181558906', $dataProviders[0]->getUri(), 'dataProvider uri must be http://viaf.org/viaf/181558906'); |
|
199 } |
|
200 |
|
201 |
|
202 /** |
|
203 * test isShownAt and isShownBy |
|
204 * |
|
205 * @return void |
|
206 */ |
|
207 public function testIsShown() { |
|
208 |
|
209 $isShownAts = $this->resGraphes['BASE']->all($this->testGraphUri, 'edm:isShownAt'); |
|
210 |
|
211 $this->assertCount(1, $isShownAts, "One edm:isShownAt"); |
|
212 $this->assertInstanceOf("EasyRdf\Resource", $isShownAts[0]); |
|
213 $this->assertEquals("http://corpusdelaparole.huma-num.fr/corpus-app#/detail/crdo-ESLO1_ENT_019", $isShownAts[0]); |
|
214 |
|
215 $isShownBys = $this->resGraphes['BASE']->all($this->testGraphUri, 'edm:isShownBy'); |
|
216 |
|
217 $this->assertCount(1, $isShownBys, "One edm:isShownBy"); |
|
218 $this->assertInstanceOf("EasyRdf\Resource", $isShownBys[0]); |
|
219 $this->assertEquals("http://cocoon.huma-num.fr/data/eslo/masters/ESLO1_ENT_019.wav", $isShownBys[0]); |
|
220 |
|
221 } |
|
222 |
|
223 /** |
|
224 * test rights |
|
225 * |
|
226 * @return void |
|
227 */ |
|
228 public function testRights() { |
|
229 $rightsNodes = $this->resGraphes['BASE']->all($this->testGraphUri, 'edm:rights'); |
|
230 |
|
231 $this->assertCount(1, $rightsNodes, "One edm:right"); |
|
232 |
|
233 $rights = $rightsNodes[0]; |
|
234 |
|
235 $this->assertTrue($rights instanceof Resource); |
|
236 |
|
237 $this->assertEquals("http://creativecommons.org/licenses/by-nc-sa/4.0/", $rights->getUri(), "right must be CC-BY-NC"); |
|
238 } |
|
239 |
|
240 /** |
|
241 * Test that the return graph has one ore:Aggregation resource |
|
242 * |
|
243 * @return void |
|
244 */ |
|
245 public function testProvidedCHO() { |
|
246 |
|
247 $resources = $this->resGraphes['BASE']->allOfType('edm:ProvidedCHO'); |
|
248 |
|
249 $this->assertCount(1, $resources, "Must found only one resources of type edm:aggregatedCHO"); |
|
250 $this->assertEquals(CocoonSoundRdfMapperTest::TEST_CHO_URI,$resources[0]); |
|
251 } |
|
252 |
|
253 /** |
|
254 * Test providedCHO identifier. |
|
255 * |
|
256 * @return void |
|
257 */ |
|
258 public function testProvidedChoId() { |
|
259 $resources = $this->resGraphes['BASE']->allOfType('edm:ProvidedCHO'); |
|
260 |
|
261 $this->assertCount(1, $resources, "Must found only one resources of type edm:ProvidedCHO"); |
|
262 $providedCHO = $resources[0]; |
|
263 |
|
264 $identifier = $providedCHO->getLiteral('<http://purl.org/dc/elements/1.1/identifier>'); |
|
265 |
|
266 $this->assertInstanceOf('EasyRdf\Literal', $identifier, "identifier value must be a literal"); |
|
267 $this->assertEquals(config('corpusparole.corpus_id_scheme') . CocoonSoundRdfMapperTest::TEST_INPUT_ID, $identifier->getValue(), "Value must be equals to ".config('corpusparole.corpus_id_scheme').CocoonSoundRdfMapperTest::TEST_INPUT_ID); |
|
268 |
|
269 } |
|
270 |
|
271 |
|
272 public function testRightsWebResourceIdentity() { |
|
273 $properties = [ |
|
274 "http://purl.org/dc/elements/1.1/rights", |
|
275 'http://purl.org/dc/terms/license', |
|
276 ]; |
|
277 |
|
278 $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type'); |
|
279 $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
280 |
|
281 foreach ($webResourceList as $webResource) { |
|
282 foreach ($properties as $prop) { |
|
283 $outputValuesStr = []; |
|
284 foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { |
|
285 array_push($outputValuesStr, strval($outputValue)); |
|
286 } |
|
287 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); |
|
288 foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { |
|
289 $this->assertContains(strval($value), $outputValuesStr, "$prop not found in output graph"); |
|
290 } |
|
291 } |
|
292 } |
|
293 } |
|
294 |
|
295 public function testRightsWebResourceTrim() { |
|
296 $properties = [ |
|
297 'http://purl.org/dc/terms/accessRights', |
|
298 ]; |
|
299 |
|
300 $webResourceList = $this->resGraphes['BASE']->all('edm:WebResource', '^rdf:type'); |
|
301 $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
302 |
|
303 foreach ($webResourceList as $webResource) { |
|
304 foreach ($properties as $prop) { |
|
305 $outputValuesStr = []; |
|
306 foreach($webResource->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { |
|
307 array_push($outputValuesStr, strval($outputValue)); |
|
308 } |
|
309 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); |
|
310 foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { |
|
311 $this->assertContains(trim(strval($value)), $outputValuesStr, "$prop not found in output graph"); |
|
312 } |
|
313 } |
|
314 } |
|
315 } |
|
316 |
|
317 /** |
|
318 * Test one to one mapping |
|
319 * |
|
320 * @return void |
|
321 */ |
|
322 public function testOneToOneProvidedCHOIdentity() { |
|
323 |
|
324 $properties = [ |
|
325 'http://purl.org/dc/terms/tableOfContents', |
|
326 'http://purl.org/dc/elements/1.1/description', |
|
327 'http://purl.org/dc/elements/1.1/language', |
|
328 'http://purl.org/dc/elements/1.1/publisher', |
|
329 'http://purl.org/dc/elements/1.1/rights', |
|
330 'http://purl.org/dc/terms/license', |
|
331 'http://purl.org/dc/elements/1.1/subject', |
|
332 'http://purl.org/dc/elements/1.1/title', |
|
333 'http://purl.org/dc/terms/available', |
|
334 'http://purl.org/dc/terms/created', |
|
335 'http://purl.org/dc/terms/issued', |
|
336 'http://purl.org/dc/terms/extent', |
|
337 'http://purl.org/dc/elements/1.1/type', |
|
338 'http://purl.org/dc/elements/1.1/language', |
|
339 'http://purl.org/dc/terms/medium', |
|
340 'http://purl.org/dc/elements/1.1/source', |
|
341 'http://purl.org/dc/terms/alternative', |
|
342 'http://purl.org/dc/terms/modified', |
|
343 'http://purl.org/dc/terms/abstract', |
|
344 'http://purl.org/dc/terms/bibliographicCitation', |
|
345 'http://purl.org/dc/elements/1.1/identifier', |
|
346 'http://purl.org/dc/terms/references', |
|
347 'http://purl.org/dc/elements/1.1/coverage', |
|
348 'http://purl.org/dc/elements/1.1/relation', |
|
349 'http://purl.org/dc/elements/1.1/creator', |
|
350 ]; |
|
351 |
|
352 $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type'); |
|
353 $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
354 |
|
355 $this->assertNotNull($providedCHO); |
|
356 $this->assertNotNull($sourceNode); |
|
357 |
|
358 foreach ($properties as $prop) { |
|
359 $outputValuesStr = []; |
|
360 foreach($providedCHO->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { |
|
361 array_push($outputValuesStr, strval($outputValue)); |
|
362 } |
|
363 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); |
|
364 foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { |
|
365 $this->assertContains(strval($value), $outputValuesStr, "$prop not found in output graph"); |
|
366 } |
|
367 } |
|
368 |
|
369 } |
|
370 |
|
371 /** |
|
372 * Test mapping for isPartOf |
|
373 * |
|
374 * @return void |
|
375 */ |
|
376 public function testOneToOneProvidedCHOIsPartOf() { |
|
377 $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type'); |
|
378 $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
379 |
|
380 $this->assertNotNull($providedCHO); |
|
381 $this->assertNotNull($sourceNode); |
|
382 |
|
383 $isGatheredInto = $providedCHO->all('<http://www.europeana.eu/schemas/edm/isGatheredInto>'); |
|
384 $this->assertCount(2, $isGatheredInto, "Must have two collection node"); |
|
385 |
|
386 $ispartOf = $providedCHO->all('<http://purl.org/dc/terms/isPartOf>'); |
|
387 $this->assertCount(1, $ispartOf, "Must have one collection node"); |
|
388 |
|
389 $outputValuesStr = []; |
|
390 foreach($providedCHO->all('<http://www.europeana.eu/schemas/edm/isGatheredInto>') as $outputValue) { |
|
391 array_push($outputValuesStr, strval($outputValue)); |
|
392 } |
|
393 $this->assertNotEmpty($outputValuesStr, "we must found some values to test isGatheredInto"); |
|
394 |
|
395 $this->assertContains(config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_LANGUESDEFRANCE", $outputValuesStr, config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_LANGUESDEFRANCE not found in output graph"); |
|
396 $this->assertContains(config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_ESLO1", $outputValuesStr, config('corpusparole.corpus_doc_id_base_uri')."crdo-COLLECTION_ESLO1 not found in output graph"); |
|
397 |
|
398 $this->assertEquals(config('corpusparole.corpus_doc_id_base_uri')."crdo-ESLO1_ENT_010", strval($providedCHO->get('<http://purl.org/dc/terms/isPartOf>')), "the isPartOf mus equals ".config('corpusparole.corpus_doc_id_base_uri')."crdo-ESLO1_ENT_010"); |
|
399 } |
|
400 |
|
401 /** |
|
402 * Test one to one mapping spatial info |
|
403 * |
|
404 * @return void |
|
405 */ |
|
406 public function testOneToOneProvidedCHOSpatial() { |
|
407 $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type'); |
|
408 $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
409 |
|
410 $this->assertNotNull($providedCHO); |
|
411 $this->assertNotNull($sourceNode); |
|
412 |
|
413 $spatials = $providedCHO->all($this->resGraphes['BASE']->resource('http://purl.org/dc/terms/spatial')); |
|
414 |
|
415 $this->assertCount(1, $spatials, "Must have only one spatial node"); |
|
416 $spatial = $spatials[0]; |
|
417 $this->assertTrue($spatial->isBNode(),"spatial node must be blank"); |
|
418 $this->assertEquals("edm:Place", $spatial->type(), "spatial node type must be edm:Place"); |
|
419 |
|
420 $lats = $spatial->all('geo:lat'); |
|
421 $this->assertCount(1, $lats, "One latitude"); |
|
422 $this->assertInstanceOf("EasyRdf\Literal", $lats[0], "Latitude must be a litteral"); |
|
423 $this->assertEquals(Literal::create("47.90", null, 'xsd:float'), $lats[0], "lat must be '47.90'^^xsd:float"); |
|
424 |
|
425 $longs = $spatial->all('geo:long'); |
|
426 $this->assertCount(1, $longs, "One longitude"); |
|
427 $this->assertInstanceOf("EasyRdf\Literal", $longs[0], "Longitude must be a litteral"); |
|
428 $this->assertEquals(Literal::create("1.90", null, 'xsd:float'), $longs[0], "long must be '1.90'^^xsd:float"); |
|
429 |
|
430 $notes = $spatial->all('skos:note'); |
|
431 $this->assertCount(2, $notes, "2 notes"); |
|
432 $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $notes, "Notes mus be only literals"); |
|
433 $this->assertEquals(Literal::create("FR", null, "dc:ISO3166"), $notes[0], "notes contains 'FR'^^dc:ISO3166"); |
|
434 $this->assertEquals(Literal::create("France, Centre, Loiret, Orléans", "fr", null), $notes[1], "notes contains 'France, Centre, Loiret, Orléans'@fr"); |
|
435 |
|
436 $sameas = $spatial->all('owl:sameAs'); |
|
437 $this->assertCount(1, $sameas, "1 same as"); |
|
438 $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources"); |
|
439 $this->assertEquals('http://vocab.getty.edu/tgn/7008337', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008337"); |
|
440 } |
|
441 |
|
442 /** |
|
443 * Test one to one mapping trim values |
|
444 * |
|
445 * @return void |
|
446 */ |
|
447 public function testOneToOneProvidedCHOTrim() { |
|
448 |
|
449 $properties = [ |
|
450 'http://purl.org/dc/terms/accessRights', |
|
451 ]; |
|
452 |
|
453 $providedCHO = $this->resGraphes['BASE']->get('edm:ProvidedCHO', '^rdf:type'); |
|
454 $sourceNode = $this->inputGraphes['BASE']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
455 |
|
456 $this->assertNotNull($providedCHO); |
|
457 $this->assertNotNull($sourceNode); |
|
458 |
|
459 foreach ($properties as $prop) { |
|
460 $outputValuesStr = []; |
|
461 foreach($providedCHO->all($this->resGraphes['BASE']->resource($prop)) as $outputValue) { |
|
462 array_push($outputValuesStr, strval($outputValue)); |
|
463 } |
|
464 $this->assertNotEmpty($outputValuesStr, 'we must found some values to test'); |
|
465 foreach ($sourceNode->all($this->inputGraphes['BASE']->resource($prop)) as $value) { |
|
466 $this->assertContains(trim(strval($value)), $outputValuesStr, "$prop not found in output graph"); |
|
467 } |
|
468 } |
|
469 } |
|
470 |
|
471 /** |
|
472 * Test one to one mapping trim values |
|
473 * |
|
474 * @return void |
|
475 */ |
|
476 public function testOneToOneProvidedCHOReference() { |
|
477 |
|
478 $providedCHO = $this->resGraphes['NO-FORMAT']->get('edm:ProvidedCHO', '^rdf:type'); |
|
479 $sourceNode = $this->inputGraphes['NO-FORMAT']->get('http://crdo.risc.cnrs.fr/schemas/Resource', '^rdf:type'); |
|
480 |
|
481 $this->assertNotNull($providedCHO); |
|
482 $this->assertNotNull($sourceNode); |
|
483 |
|
484 $outputValuesStr = []; |
|
485 foreach($providedCHO->all($this->resGraphes['NO-FORMAT']->resource('http://purl.org/dc/terms/references')) as $outputValue) { |
|
486 array_push($outputValuesStr, strval($outputValue)); |
|
487 } |
|
488 $this->assertNotEmpty($outputValuesStr, 'we must found some values to test for http://purl.org/dc/elements/1.1/reference'); |
|
489 foreach ($sourceNode->all($this->inputGraphes['NO-FORMAT']->resource('http://purl.org/dc/elements/1.1/reference')) as $value) { |
|
490 $this->assertContains(strval($value), $outputValuesStr, "http://purl.org/dc/terms/references not found in output graph"); |
|
491 } |
|
492 } |
|
493 |
|
494 |
|
495 /** |
|
496 * Test that the web resources |
|
497 * |
|
498 * @return void |
|
499 */ |
|
500 public function testWebResources() { |
|
501 |
|
502 $resources = $this->resGraphes['BASE']->allOfType('edm:WebResource'); |
|
503 |
|
504 $this->assertCount(3, $resources, "Must found three webresource"); |
|
505 |
|
506 $aggregation = $this->resGraphes['BASE']->resource($this->testGraphUri); |
|
507 |
|
508 foreach ($resources as $wres) { |
|
509 $mimetypes = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/elements/1.1/format')); |
|
510 $this->assertCount(1, $mimetypes, "Must find one mimetype."); |
|
511 $mimetype = $mimetypes[0]; |
|
512 $this->assertInstanceOf("EasyRdf\Literal", $mimetype, "mimetype must be literal"); |
|
513 $this->assertEquals("dc:IMT",$mimetype->getDatatype()); |
|
514 |
|
515 $extends = $wres->all($this->resGraphes['BASE']->resource('http://purl.org/dc/terms/extent')); |
|
516 $this->assertCount(1, $extends, "Must find one extent."); |
|
517 $extent = $extends[0]; |
|
518 $this->assertInstanceOf("EasyRdf\Literal", $extent, "extent must be literal"); |
|
519 $this->assertStringStartsWith("PT", $extent->getValue(), "value mus start with PT"); |
|
520 |
|
521 if($wres->hasProperty('edm:isDerivativeOf')) { |
|
522 $derivative = $wres->get('edm:isDerivativeOf'); |
|
523 $this->assertInstanceOf("EasyRdf\Resource", $derivative, "Derivative must be a resource"); |
|
524 $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"); |
|
525 $this->assertTrue($aggregation->hasProperty('edm:hasView', $wres)); |
|
526 } |
|
527 else { |
|
528 $this->assertTrue($aggregation->hasProperty('edm:isShownBy', $wres)); |
|
529 } |
|
530 |
|
531 } |
|
532 } |
|
533 |
|
534 /** |
|
535 * Test that the web resources |
|
536 * |
|
537 * @return void |
|
538 */ |
|
539 public function testWebResourcesDate() { |
|
540 |
|
541 $resources = $this->resGraphes['BASE']->allOfType('edm:WebResource'); |
|
542 |
|
543 foreach ($resources as $wres) { |
|
544 $this->assertFalse($wres->hasProperty("http://purl.org/dc/terms/available"),"web resource must not have http://purl.org/dc/terms/available"); |
|
545 $this->assertFalse($wres->hasProperty("http://purl.org/dc/terms/modified"),"web resource must not have http://purl.org/dc/terms/modified"); |
|
546 $this->assertTrue($wres->hasProperty("http://purl.org/dc/terms/issued"), "Must have http://purl.org/dc/terms/issued"); |
|
547 $this->assertTrue($wres->hasProperty("http://purl.org/dc/terms/created"), "Must have http://purl.org/dc/terms/created"); |
|
548 |
|
549 $issued = $wres->getLiteral('dc:issued'); |
|
550 //<http://purl.org/dc/terms/issued> "2014-12-05T15:00:19+01:00"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
551 $this->assertInstanceOf('EasyRdf\Literal', $issued, "issued value must be a literal"); |
|
552 $this->assertEquals('http://purl.org/dc/terms/W3CDTF', $issued->getDatatypeUri(), "issued datatype uri must be a http://purl.org/dc/terms/W3CDTF"); |
|
553 $this->assertEquals('2014-12-05T15:00:19+01:00', $issued->getValue(), "Value must be 2014-12-05T15:00:19+01:00"); |
|
554 |
|
555 $created = $wres->getLiteral('dc:created'); |
|
556 //<http://purl.org/dc/terms/created> "1969-04-11"^^<http://purl.org/dc/terms/W3CDTF> ; |
|
557 $this->assertInstanceOf('EasyRdf\Literal', $created, "created value must be a literal"); |
|
558 $this->assertEquals('http://purl.org/dc/terms/W3CDTF', $created->getDatatypeUri(), "created datatype uri must be a http://purl.org/dc/terms/W3CDTF"); |
|
559 $this->assertEquals('1969-04-11', $created->getValue(), "Value must be 1969-04-11"); |
|
560 |
|
561 } |
|
562 |
|
563 } |
|
564 |
|
565 /** |
|
566 * Test collection graph creation |
|
567 * @return void |
|
568 */ |
|
569 public function testCollectionGraph() { |
|
570 $outputs = $this->mappers['BASE']->getOutputGraphes(); |
|
571 $this->assertCount(3, $outputs, "Must have 3 graphes as output"); |
|
572 foreach($outputs as $url => $outputGraph) { |
|
573 if($outputGraph->getUri() == config('corpusparole.corpus_doc_id_base_uri').'crdo-ESLO1_ENT_019') { |
|
574 continue; |
|
575 } |
|
576 $this->assertContains($outputGraph->getUri(), [config('corpusparole.corpus_doc_id_base_uri').'crdo-COLLECTION_LANGUESDEFRANCE', config('corpusparole.corpus_doc_id_base_uri').'crdo-COLLECTION_ESLO1']); |
|
577 $this->assertEquals($outputGraph->resource($outputGraph->getUri())->type(), 'edm:Collection'); |
|
578 } |
|
579 } |
|
580 |
|
581 } |