--- a/server/src/tests/Libraries/Mergers/CocoonSoundRdfMergerTest.php Sun Jun 05 00:28:45 2016 +0200
+++ b/server/src/tests/Libraries/Mergers/CocoonSoundRdfMergerTest.php Mon Jun 06 01:10:25 2016 +0200
@@ -18,7 +18,8 @@
'BASE' => __DIR__.'/files/CocoonSoundRdfMergerTest/base_doc.ttl',
'SOURCE' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_doc.ttl',
'BASE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/base_no_spatial.ttl',
- 'SOURCE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_no_spatial.ttl'
+ 'SOURCE_NO_SPATIAL' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_no_spatial.ttl',
+ 'SOURCE_MORE_SPATIAL_NOTES' => __DIR__.'/files/CocoonSoundRdfMergerTest/source_more_spatial_notes.ttl'
];
const TEST_INPUT_ID = "crdo-ESLO1_ENT_019";
@@ -170,9 +171,10 @@
$this->assertEquals(Literal::create("Other place very important", "fr", null), $notes[2], "notes contains 'Other place very important'@fr");
$sameas = $spatial->all('owl:sameAs');
- $this->assertCount(1, $sameas, "1 same as");
+ $this->assertCount(2, $sameas, "2 same as");
$this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources");
$this->assertEquals('http://vocab.getty.edu/tgn/7008038', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008038");
+ $this->assertEquals('http://vocab.getty.edu/tgn/1234567890', $sameas[1]->getUri(), "uri must be http://vocab.getty.edu/tgn/1234567890");
}
@@ -317,4 +319,51 @@
}
}
+ /**
+ * Test one to one mapping spatial info
+ *
+ * @return void
+ */
+
+ public function testProvidedCHOSpatialMore() {
+ $merger = new CocoonSoundRdfMerger();
+ $this->resGraph['MORE_SPATIAL_NOTES'] = $merger->mergeGraph($this->inputGraphes['BASE'], $this->inputGraphes['SOURCE_MORE_SPATIAL_NOTES']);
+
+ $providedCHO = $this->resGraph['MORE_SPATIAL_NOTES']->get('edm:ProvidedCHO', '^rdf:type');
+
+ $this->assertNotNull($providedCHO);
+
+ $spatials = $providedCHO->all($this->resGraph['MORE_SPATIAL_NOTES']->resource('http://purl.org/dc/terms/spatial'));
+
+ $this->assertCount(1, $spatials, "Must have only one spatial node");
+ $spatial = $spatials[0];
+ $this->assertTrue($spatial->isBNode(),"spatial node must be blank");
+ $this->assertEquals("edm:Place", $spatial->type(), "spatial node type must be edm:Place");
+
+ $lats = $spatial->all('geo:lat');
+ $this->assertCount(1, $lats, "One latitude");
+ $this->assertInstanceOf("EasyRdf\Literal", $lats[0], "Latitude must be a litteral");
+ $this->assertEquals(Literal::create("48.83975", null, 'xsd:float'), $lats[0], "lat must be '48.83975'^^xsd:float");
+
+ $longs = $spatial->all('geo:long');
+ $this->assertCount(1, $longs, "One longitude");
+ $this->assertInstanceOf("EasyRdf\Literal", $longs[0], "Longitude must be a litteral");
+ $this->assertEquals(Literal::create("2.3542", null, 'xsd:float'), $longs[0], "long must be '2.3542'^^xsd:float");
+
+ $notes = $spatial->all('skos:note');
+ $this->assertCount(4, $notes, "4 notes");
+ $this->assertContainsOnlyInstancesOf("EasyRdf\Literal", $notes, "Notes must be only literals");
+ $this->assertEquals(Literal::create("FR", null, "dc:ISO3166"), $notes[0], "notes contains 'FR'^^dc:ISO3166");
+ $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");
+ $this->assertEquals(Literal::create("Other place very important", "en", null), $notes[2], "notes contains 'Other place very important'@en");
+ $this->assertEquals(Literal::create("Autre place importante", "fr", null), $notes[3], "notes contains 'Autre place importante'@fr");
+
+ $sameas = $spatial->all('owl:sameAs');
+ $this->assertCount(2, $sameas, "2 same as");
+ $this->assertContainsOnlyInstancesOf("EasyRdf\Resource", $sameas, "Notes mus be only resources");
+ $this->assertEquals('http://vocab.getty.edu/tgn/7008038', $sameas[0]->getUri(), "uri must be http://vocab.getty.edu/tgn/7008038");
+ $this->assertEquals('http://vocab.getty.edu/tgn/1234567890', $sameas[1]->getUri(), "uri must be http://vocab.getty.edu/tgn/1234567890");
+ }
+
+
}