Skip to content
Snippets Groups Projects
Commit 0631bb67 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

dev #93423 : add location coordinates to libraries JSON export

parent da2c827a
Branches
Tags
4 merge requests!3297WIP: Master,!3284Master,!3277dev #93423 : add location coordinates to libraries JSON export,!3273dev #93423 : add location coordinates to libraries JSON export
Pipeline #8472 passed with stage
in 42 minutes and 55 seconds
- ticket #93423 : Open Data : Ajout des coordonnées du lieu dans la liste des bibliothèques en JSON
\ No newline at end of file
......@@ -85,6 +85,16 @@ class BibController extends ZendAfi_Controller_Action {
$fields['openings'] = $openings;
$fields['latitude'] = '';
$fields['longitude'] = '';
if (($location = $library->getLieu())
&& $location->hasLatitude()
&& $location->hasLongitude()) {
$fields['latitude'] = $location->getLatitude();
$fields['longitude'] = $location->getLongitude();
}
return $fields;
}
......
......@@ -111,7 +111,9 @@ class BibControllerIndexActionTest extends AbstractControllerTestCase {
class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase {
protected $_storm_default_to_volatile = true, $_json;
protected
$_storm_default_to_volatile = true,
$_json;
public function setUp() {
parent::setUp();
......@@ -125,7 +127,10 @@ class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase
'ville' => 'Annecy',
'url_web' => '',
'cp' => '74000',
'ouvertures' => $ouvertures]);
'ouvertures' => $ouvertures,
'lieu' => $this->fixture('Class_Lieu',
['id' => 44,
'libelle' => 'Annecy'])]);
$this->fixture('Class_Bib',
['id' => 586,
......@@ -134,7 +139,12 @@ class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase
'ville' => 'Cran-Gevrier',
'cp' => '74960',
'url_web' => '',
'gln' => 'UN GROS GLN']);
'gln' => 'UN GROS GLN',
'lieu' => $this->fixture('Class_Lieu',
['id' => 45,
'libelle' => 'Cran',
'latitude' => '45.90644',
'longitude' => '6.10739'])]);
$this->fixture('Class_CustomField',
['id' => 7,
......@@ -157,48 +167,75 @@ class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase
$annecy->saveWithCustomFields();
$this->dispatch('opac/bib/index/format/json', true);
$this->_json = $this->_response->getBody();
$this->_json = json_decode($this->_response->getBody());
}
/** @test */
public function jsonShouldContainsLabelMediathequeAnnecy() {
$this->assertContains('M\u00e9diath\u00e8que d\'Annecy', $this->_json);
public function firstLabelShouldBeMediathequeAnnecy() {
$this->assertEquals('Médiathèque d\'Annecy', $this->_json[0]->libelle);
}
/** @test */
public function jsonShouldContainsLabelMediathequeDeCran() {
$this->assertContains('M\u00e9diath\u00e8que de Cran', $this->_json);
public function secondLabelShouldBeMediathequeDeCran() {
$this->assertEquals('Médiathèque de Cran', $this->_json[1]->libelle);
}
/** @test */
public function jsonShouldNotContainsUnGrosGln() {
$this->assertNotContains('UN GROS GLN', $this->_json);
public function cranGlnShouldNotBeSet() {
$this->assertFalse(isset($this->_json[1]->gln));
}
/** @test */
public function jsonShouldContainsRestauration() {
$this->assertContains('Restauration', $this->_json);
public function annecyLatitudeShouldBeEmpty() {
$this->assertEquals('', $this->_json[0]->latitude);
}
/** @test */
public function jsonShouldContainsServices() {
$this->assertContains('Services', $this->_json);
public function cranLatitudeShouldBe45() {
$this->assertEquals('45.90644', $this->_json[1]->latitude);
}
/** @test */
public function jsonShouldContainsPublic() {
$this->assertContains('Public', $this->_json);
public function cranLongitudeShouldBe6() {
$this->assertEquals('6.10739', $this->_json[1]->longitude);
}
/** @test */
public function jsonShouldContainsMardi() {
$this->assertContains('"jour_semaine":2', $this->_json);
public function annecyShouldHave2CustomFields() {
$this->assertEquals(2, count($this->_json[0]->custom_fields));
return $this->_json[0]->custom_fields;
}
/**
* @test
* @depends annecyShouldHave2CustomFields
*/
public function firstAnnecyFieldShouldBePublic($fields) {
$this->assertEquals('Public', $fields[0]->label);
$this->assertEquals('', $fields[0]->value);
}
/**
* @test
* @depends annecyShouldHave2CustomFields
*/
public function secondAnnecyFieldShouldBeServices($fields) {
$this->assertEquals('Services', $fields[1]->label);
$this->assertEquals('Wifi;Restauration', $fields[1]->value);
}
/** @test */
public function annecyShouldBeOpenedTuesday() {
$this->assertEquals('2', $this->_json[0]->openings[0]->jour_semaine);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment