diff --git a/VERSIONS_HOTLINE/53371 b/VERSIONS_HOTLINE/53371 new file mode 100644 index 0000000000000000000000000000000000000000..2dd39fe16c852f0f30c0a35a7267657c690f934f --- /dev/null +++ b/VERSIONS_HOTLINE/53371 @@ -0,0 +1 @@ + - ticket #53371 : Fiche bibliothèque : affichage du lien 'voir le plan' lorsque le lieu est renseigné \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/BibView.php b/library/ZendAfi/View/Helper/BibView.php index c6c65aef9e43f978e1065d4019077b45d42c5ccf..44d735907f403e7ce7284af9e25a53e9132ca8b0 100644 --- a/library/ZendAfi/View/Helper/BibView.php +++ b/library/ZendAfi/View/Helper/BibView.php @@ -65,7 +65,11 @@ class ZendAfi_View_Helper_BibView extends ZendAfi_View_Helper_BaseHelper { protected function _renderPicture() { - $map = (trim($this->bib->getGoogleMap()) !== '') ? $this->_getMap() : ''; + $map = ((trim($this->bib->getGoogleMap()) !== '') + || + ($this->bib->hasLatitude() && $this->bib->hasLongitude())) + ? $this->_getMap() + : ''; return $this->_tag('dd', $this->view->libraryPicture($this->bib) . $map, diff --git a/tests/library/ZendAfi/View/Helper/BibViewTest.php b/tests/library/ZendAfi/View/Helper/BibViewTest.php index f128651af7fa618309c52d7a6f0cf1b0b4e5f164..6399e8adeea54d6dadbc3d366ef119e522cd1c13 100644 --- a/tests/library/ZendAfi/View/Helper/BibViewTest.php +++ b/tests/library/ZendAfi/View/Helper/BibViewTest.php @@ -39,10 +39,10 @@ class BibViewTest extends ViewHelpertestCase { 'visibilite' => Class_Bib::V_DATA]); - $helper = new ZendAfi_View_Helper_BibView(); - $helper->setView(new ZendAfi_Controller_Action_Helper_View()); + $this->_helper = new ZendAfi_View_Helper_BibView(); + $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->html = $helper->bibView(Class_Bib::find(4), '/back'); + $this->html = $this->_helper->bibView(Class_Bib::find(4), '/back'); } @@ -53,6 +53,43 @@ class BibViewTest extends ViewHelpertestCase { } + /** @test */ + public function withoutLieuLinkToMapViewShouldNotBePresent() { + $this->assertNotXPath($this->html, '//a[contains(@href, "mapview")]'); + } + + + /** @test */ + public function withUnmappableLieuLinkToMapViewShouldNotBePresent() { + $this + ->bib_annecy + ->setLieu($this->fixture('Class_Lieu', + ['id' => 3, + 'libelle' => 'Nowhere', + 'latitude' => '', + 'longitude'=> ''])) + ->assertSave(); + $this->assertNotXPath($this->_helper->bibView(Class_Bib::find(4)), + '//a[contains(@href, "mapview")]'); + } + + +/** @test */ + public function withMappableLieuLinkToMapViewShouldBePresent() { + $this + ->bib_annecy + ->setLieu($this->fixture('Class_Lieu', + ['id' => 3, + 'libelle' => 'Bonlieu', + 'latitude' => '0.5', + 'longitude'=> '0.5'])) + ->assertSave(); + $this->assertXPathContentContains($this->_helper->bibView(Class_Bib::find(4)), + '//a[contains(@href, "mapview/id_bib/4")]', + 'Voir le plan'); + } + + /** @test */ public function telephoneShouldBeDisplayed() { $this->assertXPathContentContains($this->html, '//div[1]//dd[@class="phone"]', '04 50 51 32 12');