16 |
16 |
17 const TEST_INPUT_DOCS = [ |
17 const TEST_INPUT_DOCS = [ |
18 'BASE' => __DIR__.'/files/CocoonSoundRdfMergerTest/base_doc.ttl', |
18 'BASE' => __DIR__.'/files/CocoonSoundRdfMergerTest/base_doc.ttl', |
19 'SOURCE' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_doc.ttl', |
19 'SOURCE' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_doc.ttl', |
20 'BASE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/base_no_spatial.ttl', |
20 'BASE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/base_no_spatial.ttl', |
21 'SOURCE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_no_spatial.ttl' |
21 'SOURCE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_no_spatial.ttl', |
|
22 'SOURCE_MORE_SPATIAL_NOTES' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_more_spatial_notes.ttl' |
22 ]; |
23 ]; |
23 |
24 |
24 const TEST_INPUT_ID = "crdo-ESLO1_ENT_019"; |
25 const TEST_INPUT_ID = "crdo-ESLO1_ENT_019"; |
25 const TEST_GRAPH_URI = "http://corpusdelaparole.huma-num.fr/corpus/res/crdo-ESLO1_ENT_019"; |
26 const TEST_GRAPH_URI = "http://corpusdelaparole.huma-num.fr/corpus/res/crdo-ESLO1_ENT_019"; |
26 const TEST_CHO_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019"; |
27 const TEST_CHO_URI = "http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-ESLO1_ENT_019"; |
168 $this->assertEquals(Literal::create("FR", null, "dc:ISO3166"), $notes[0], "notes contains 'FR'^^dc:ISO3166"); |
169 $this->assertEquals(Literal::create("FR", null, "dc:ISO3166"), $notes[0], "notes contains 'FR'^^dc:ISO3166"); |
169 $this->assertEquals(Literal::create("France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier", "fr", null), $notes[1], "notes contains 'France, Centre, Loiret, Orléans'@fr"); |
170 $this->assertEquals(Literal::create("France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier", "fr", null), $notes[1], "notes contains 'France, Centre, Loiret, Orléans'@fr"); |
170 $this->assertEquals(Literal::create("Other place very important", "fr", null), $notes[2], "notes contains 'Other place very important'@fr"); |
171 $this->assertEquals(Literal::create("Other place very important", "fr", null), $notes[2], "notes contains 'Other place very important'@fr"); |
171 |
172 |
172 $sameas = $spatial->all('owl:sameAs'); |
173 $sameas = $spatial->all('owl:sameAs'); |
173 $this->assertCount(1, $sameas, "1 same as"); |
174 $this->assertCount(2, $sameas, "2 same as"); |
174 $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources"); |
175 $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources"); |
175 $this->assertEquals('http://vocab.getty.edu/tgn/7008038', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008038"); |
176 $this->assertEquals('http://vocab.getty.edu/tgn/7008038', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008038"); |
|
177 $this->assertEquals('http://vocab.getty.edu/tgn/1234567890', $sameas[1]->getUri(), "uri must be http://vocab.getty.edu/tgn/1234567890"); |
176 } |
178 } |
177 |
179 |
178 |
180 |
179 public function testProvidedCHOSpatialNoSource() { |
181 public function testProvidedCHOSpatialNoSource() { |
180 $merger = new CocoonSoundRdfMerger(); |
182 $merger = new CocoonSoundRdfMerger(); |
315 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); |
317 $this->assertNotEmpty($outputValuesStr, "we must found some values to test $prop"); |
316 } |
318 } |
317 } |
319 } |
318 } |
320 } |
319 |
321 |
|
322 /** |
|
323 * Test one to one mapping spatial info |
|
324 * |
|
325 * @return void |
|
326 */ |
|
327 |
|
328 public function testProvidedCHOSpatialMore() { |
|
329 $merger = new CocoonSoundRdfMerger(); |
|
330 $this->resGraph['MORE_SPATIAL_NOTES'] = $merger->mergeGraph($this->inputGraphes['BASE'], $this->inputGraphes['SOURCE_MORE_SPATIAL_NOTES']); |
|
331 |
|
332 $providedCHO = $this->resGraph['MORE_SPATIAL_NOTES']->get('edm:ProvidedCHO', '^rdf:type'); |
|
333 |
|
334 $this->assertNotNull($providedCHO); |
|
335 |
|
336 $spatials = $providedCHO->all($this->resGraph['MORE_SPATIAL_NOTES']->resource('http://purl.org/dc/terms/spatial')); |
|
337 |
|
338 $this->assertCount(1, $spatials, "Must have only one spatial node"); |
|
339 $spatial = $spatials[0]; |
|
340 $this->assertTrue($spatial->isBNode(),"spatial node must be blank"); |
|
341 $this->assertEquals("edm:Place", $spatial->type(), "spatial node type must be edm:Place"); |
|
342 |
|
343 $lats = $spatial->all('geo:lat'); |
|
344 $this->assertCount(1, $lats, "One latitude"); |
|
345 $this->assertInstanceOf("EasyRdf\Literal", $lats[0], "Latitude must be a litteral"); |
|
346 $this->assertEquals(Literal::create("48.83975", null, 'xsd:float'), $lats[0], "lat must be '48.83975'^^xsd:float"); |
|
347 |
|
348 $longs = $spatial->all('geo:long'); |
|
349 $this->assertCount(1, $longs, "One longitude"); |
|
350 $this->assertInstanceOf("EasyRdf\Literal", $longs[0], "Longitude must be a litteral"); |
|
351 $this->assertEquals(Literal::create("2.3542", null, 'xsd:float'), $longs[0], "long must be '2.3542'^^xsd:float"); |
|
352 |
|
353 $notes = $spatial->all('skos:note'); |
|
354 $this->assertCount(4, $notes, "4 notes"); |
|
355 $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $notes, "Notes must be only literals"); |
|
356 $this->assertEquals(Literal::create("FR", null, "dc:ISO3166"), $notes[0], "notes contains 'FR'^^dc:ISO3166"); |
|
357 $this->assertEquals(Literal::create("France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier", "fr", null), $notes[1], "notes contains 'France, Centre, Loiret, Orléans'@fr"); |
|
358 $this->assertEquals(Literal::create("Other place very important", "en", null), $notes[2], "notes contains 'Other place very important'@en"); |
|
359 $this->assertEquals(Literal::create("Autre place importante", "fr", null), $notes[3], "notes contains 'Autre place importante'@fr"); |
|
360 |
|
361 $sameas = $spatial->all('owl:sameAs'); |
|
362 $this->assertCount(2, $sameas, "2 same as"); |
|
363 $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources"); |
|
364 $this->assertEquals('http://vocab.getty.edu/tgn/7008038', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008038"); |
|
365 $this->assertEquals('http://vocab.getty.edu/tgn/1234567890', $sameas[1]->getUri(), "uri must be http://vocab.getty.edu/tgn/1234567890"); |
|
366 } |
|
367 |
|
368 |
320 } |
369 } |