server/src/tests/Models/GeoResourceTest.php
changeset 171 f4f558f04f37
parent 169 8fddc113095e
child 277 bd4bc1db4f40
equal deleted inserted replaced
170:31bee084df32 171:f4f558f04f37
   113         <http://purl.org/dc/terms/spatial> [
   113         <http://purl.org/dc/terms/spatial> [
   114             a <http://www.europeana.eu/schemas/edm/Place> ;
   114             a <http://www.europeana.eu/schemas/edm/Place> ;
   115             <http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr
   115             <http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr
   116         ] .
   116         ] .
   117 EOT
   117 EOT
       
   118         ,
       
   119         "LOC3" => <<<EOT
       
   120     @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
       
   121     @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
       
   122     @prefix sesame: <http://www.openrdf.org/schema/sesame#> .
       
   123     @prefix owl: <http://www.w3.org/2002/07/owl#> .
       
   124     @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
       
   125     @prefix fn: <http://www.w3.org/2005/xpath-functions#> .
       
   126 
       
   127     <http://purl.org/poi/crdo.vjf.cnrs.fr/crdo-CFPP2000_35_SOUND> a <http://www.europeana.eu/schemas/edm/ProvidedCHO> ;
       
   128         <http://purl.org/dc/terms/accessRights> "Freely available for non-commercial use" ;
       
   129         <http://purl.org/dc/terms/created> "2010-11-17"^^<http://purl.org/dc/terms/W3CDTF> ;
       
   130         <http://purl.org/dc/terms/extent> "PT48M26S" ;
       
   131         <http://purl.org/dc/terms/issued> "2013-10-12T14:35:57+02:00"^^<http://purl.org/dc/terms/W3CDTF> ;
       
   132         <http://purl.org/dc/terms/license> <http://creativecommons.org/licenses/by-nc-sa/3.0/> ;
       
   133         <http://purl.org/dc/elements/1.1/description> "Enregistrement issu du Corpus de Français Parlé Parisien des années 2000 (CFPP2000)"@fr , "Quartier(s) concerné(s) : Paris 3e, et 20e (pour l'âge adulte); Anonymisation : Noalig TANGUY;"@fr ;
       
   134         <http://purl.org/dc/elements/1.1/identifier> "ark:/87895/1.17-375004" , "%2\$scrdo-CFPP2000_35_SOUNDid" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35" , "Cote producteur: [03-01] Ozgur_Kilic_H_32_alii_3e"@fr , "ark:/87895/1.17-372593" , "oai:crdo.vjf.cnrs.fr:crdo-CFPP2000_35_SOUND" ;
       
   135         <http://purl.org/dc/elements/1.1/language> <http://lexvo.org/id/iso639-3/fra> ;
       
   136         <http://purl.org/dc/elements/1.1/publisher> <http://viaf.org/viaf/142432638>;
       
   137         <http://purl.org/dc/elements/1.1/title> "Entretien de Ozgur Kiliç 2"@fr ;
       
   138         <http://purl.org/dc/terms/available> "2013-10-12"^^<http://purl.org/dc/terms/W3CDTF> ;
       
   139         <http://purl.org/dc/terms/spatial> [
       
   140             a <http://www.europeana.eu/schemas/edm/Place> ;
       
   141             owl:sameAs <http://sws.geonames.org/6618626/> ;
       
   142             owl:sameAs <http://fr.dbpedia.org/resource/Gramazie> ;
       
   143             <http://www.w3.org/2004/02/skos/core#note> "FR"^^<http://purl.org/dc/terms/ISO3166> , "France, Île-de-France, Paris, Université Sorbonne Nouvelle Paris 3, site Censier"@fr , "Domicile de Ozgur Kiliç"@fr , "France, Île-de-France, Paris 20"@fr
       
   144         ] .
       
   145 EOT
   118     ];
   146     ];
   119 
   147 
   120     public function setUp() {
   148     public function setUp() {
   121 
   149 
   122         parent::setup();
   150         parent::setup();
   149     }
   177     }
   150 
   178 
   151     public function testGetRefLoc() {
   179     public function testGetRefLoc() {
   152         $geoResource = $this->getGeoResource("LOC1");
   180         $geoResource = $this->getGeoResource("LOC1");
   153 
   181 
   154         $refLoc = $geoResource->getRefLoc();
   182         $refLoc = $geoResource->getRefLocs();
   155 
   183 
   156         $this->assertEquals('http://sws.geonames.org/6618626/', $refLoc);
   184         $this->assertEquals(['http://sws.geonames.org/6618626/'], $refLoc);
   157 
   185 
   158     }
   186     }
   159 
   187 
   160     public function testGetRefLocNull() {
   188     public function testGetRefLocNull() {
   161         $geoResource = $this->getGeoResource("LOC2");
   189         $geoResource = $this->getGeoResource("LOC2");
   162 
   190 
   163         $refLoc = $geoResource->getRefLoc();
   191         $refLoc = $geoResource->getRefLocs();
   164 
   192 
   165         $this->assertNull($refLoc);
   193         $this->assertEmpty($refLoc);
       
   194 
       
   195     }
       
   196 
       
   197     public function testGetRefLocMultiple() {
       
   198         $geoResource = $this->getGeoResource("LOC3");
       
   199 
       
   200         $refLocs = $geoResource->getRefLocs();
       
   201 
       
   202         $this->assertTrue(is_array($refLocs));
       
   203         $this->assertCount(2,$refLocs);
       
   204         $this->assertEquals(['http://sws.geonames.org/6618626/', 'http://fr.dbpedia.org/resource/Gramazie'], $refLocs);
       
   205 
   166 
   206 
   167     }
   207     }
   168 
   208 
   169     public function testNotes() {
   209     public function testNotes() {
   170         $geoResource = $this->getGeoResource("LOC1");
   210         $geoResource = $this->getGeoResource("LOC1");
   182     public function testJsonSerialize() {
   222     public function testJsonSerialize() {
   183         $geoResource = $this->getGeoResource("LOC1");
   223         $geoResource = $this->getGeoResource("LOC1");
   184 
   224 
   185         $json = $geoResource->jsonSerialize();
   225         $json = $geoResource->jsonSerialize();
   186 
   226 
   187         $this->assertEquals(["ref-loc", "notes"], array_keys($json));
   227         $this->assertEquals(["ref-locs", "notes"], array_keys($json));
   188         $this->assertEquals("http://sws.geonames.org/6618626/", $json['ref-loc']);
   228         $this->assertEquals(["http://sws.geonames.org/6618626/"], $json['ref-locs']);
   189 
   229 
   190         $notes = $json['notes'];
   230         $notes = $json['notes'];
   191         $this->assertTrue(is_array($notes));
   231         $this->assertTrue(is_array($notes));
   192         $this->assertCount(4, $notes);
   232         $this->assertCount(4, $notes);
   193 
   233 
   197     public function testJsonSerializeNull() {
   237     public function testJsonSerializeNull() {
   198         $geoResource = $this->getGeoResource("LOC2");
   238         $geoResource = $this->getGeoResource("LOC2");
   199 
   239 
   200         $json = $geoResource->jsonSerialize();
   240         $json = $geoResource->jsonSerialize();
   201 
   241 
   202         $this->assertNull($json['ref-loc']);
   242         $this->assertEmpty($json['ref-locs']);
       
   243 
       
   244     }
       
   245 
       
   246     public function testJsonSerializeMultipleRefLocs() {
       
   247         $geoResource = $this->getGeoResource("LOC3");
       
   248 
       
   249         $json = $geoResource->jsonSerialize();
       
   250 
       
   251         $this->assertEquals(["ref-locs", "notes"], array_keys($json));
       
   252         $this->assertEquals(["http://sws.geonames.org/6618626/", "http://fr.dbpedia.org/resource/Gramazie"], $json['ref-locs']);
   203 
   253 
   204     }
   254     }
   205 
   255 
   206 
   256 
   207 }
   257 }