From 9a069793449acbb30b41595d98e629aa74058050 Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Mon, 29 Oct 2018 16:39:22 +0100 Subject: [PATCH] dev #78195 add ical link only on articles that are events --- .../View/Helper/Article/RenderFullContent.php | 11 +++++---- .../opac/controllers/CmsControllerTest.php | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/library/ZendAfi/View/Helper/Article/RenderFullContent.php b/library/ZendAfi/View/Helper/Article/RenderFullContent.php index cfb3fb010c4..b27c4ea50cb 100644 --- a/library/ZendAfi/View/Helper/Article/RenderFullContent.php +++ b/library/ZendAfi/View/Helper/Article/RenderFullContent.php @@ -35,10 +35,13 @@ class ZendAfi_View_Helper_Article_RenderFullContent extends ZendAfi_View_Helper_ public function renderICalLink($article) { - return $this->view->tagICal(Class_Url::absolute(['controller' => 'cms', - 'action' => 'ical', - 'id_article' => $article->getId()]), - $this->view->_('Ajouter au calendrier')); + return + $article->hasEventsDebut() + ? $this->view->tagICal(Class_Url::absolute(['controller' => 'cms', + 'action' => 'ical', + 'id_article' => $article->getId()]), + $this->view->_('Ajouter au calendrier')) + : ''; } } diff --git a/tests/application/modules/opac/controllers/CmsControllerTest.php b/tests/application/modules/opac/controllers/CmsControllerTest.php index ef87de64f24..6e42f0cf26e 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -819,8 +819,8 @@ class CmsControllerArticleViewByDateWithRadioFullArticleSelectedTest extends Abs /** @test */ public function feteDeLaBananeShouldContainsLinkToIcal() { - $this->assertXpath('//div[@class="ical"]/a[contains(@href, "/cms/ical/id_article/1")]', - $this->_response->getBody()); + $this->assertXpathContentContains('//a[@class="ical"][contains(@href, "/cms/ical/id_article/1")]', + 'Ajouter au calendrier'); } } @@ -844,9 +844,7 @@ abstract class CmsControllerWithFeteDeLaFriteTestCase extends AbstractController ['id' => '4156465', 'libelle' => 'Annecy', 'adresse' => 'Rue des tomates', - 'code_postal' => '74000', - 'latitude' => '45.9262592', - 'longitude' => '6.1459837']); + 'code_postal' => '74000']); $alimentaire = $this->fixture ( 'Class_ArticleCategorie', ['id' => 1, 'libelle' => 'Alimentaire', @@ -1171,7 +1169,7 @@ class CmsControllerArticleViewTest extends CmsControllerWithFeteDeLaFriteTestCas /** @test */ - public function withCurrentLocaleEnShouldReturnEnglishTranslation() { + function withCurrentLocaleEnShouldReturnEnglishTranslation() { $this->bootstrap(); Zend_Registry::get('session')->language = 'en'; $this->dispatch('/cms/articleview/id/224'); @@ -1186,14 +1184,14 @@ class CmsControllerArticleViewTest extends CmsControllerWithFeteDeLaFriteTestCas /** @test */ - public function divShouldContainsAdresseBonlieu() { + function divShouldContainsAdresseBonlieu() { $this->assertXPathContentContains('//div[@class="lieu"]', 'Annecy'); } /** @test */ - public function divShouldContainsStaticMap() { - $this->assertXPath('//div[@class="lieu"]//img[contains(@src,"https://smap.afi-sa.net/staticmap.php")]'); + function divShouldContainsGoogleMap() { + $this->assertXPath('//div[@class="lieu"]//img[contains(@src,"https://maps.googleapis.com/maps")]'); } @@ -1832,6 +1830,13 @@ class CmsControllerWithArticleWithWallKioskTest extends CmsControllerWithArticle } + /** @test */ + public function pageShouldNotContainsLinkToIcal() { + $this->assertNotXPath('//a[contains(@href, "/cms/ical")]'); + } + + + /** @test */ public function pageShouldContainsKiosk() { $this->assertXPath( '//div[@class="liste_mur"]');; -- GitLab