diff --git a/library/ZendAfi/View/Helper/ReseauxSociaux.php b/library/ZendAfi/View/Helper/ReseauxSociaux.php index 91028085b8f89aa1e6a321f315550759d805b8b8..00cc56d89488a10707ca0bf07086353f95f19a26 100644 --- a/library/ZendAfi/View/Helper/ReseauxSociaux.php +++ b/library/ZendAfi/View/Helper/ReseauxSociaux.php @@ -33,7 +33,9 @@ class ZendAfi_View_Helper_ReseauxSociaux extends ZendAfi_View_Helper_BaseHelper switch($type) { case "notice" : - $notice = Class_Notice::find($id_notice); + if (!$notice = Class_Notice::find($id_notice)) + return ''; + $url_portail="/recherche/viewnotice/clef/".$notice->getClefAlpha()."?id_profil=".$id_profil."&type_doc=".$notice->getTypeDoc(); $message = $notice->getTitrePrincipal(); break; diff --git a/tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php b/tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php index df1bf2f8dff16e90d1a1e9e5f249408c0e5c3413..be8db40bafd360003232697441f6c977b3ffb577 100644 --- a/tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php +++ b/tests/library/ZendAfi/View/Helper/ResauxSociauxTest.php @@ -20,7 +20,7 @@ */ -class ZendAfi_View_Helper_ReseauxSociauxForArticleTest extends ViewHelperTestCase { +class ZendAfi_View_Helper_ReseauxSociauxTest extends ViewHelperTestCase { /** @var ZendAfi_View_Helper_ReseauxSociaux */ protected $_helper; @@ -32,14 +32,22 @@ class ZendAfi_View_Helper_ReseauxSociauxForArticleTest extends ViewHelperTestCas $_SERVER["HTTP_HOST"] = 'localhost'; $this->_helper = new ZendAfi_View_Helper_ReseauxSociaux(); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - $this->_html = $this->_helper->reseauxSociaux('article', 123456789); } /** @test */ - public function linkShouldExpectationArticleId() { + public function onArticlelinkShouldContainsArticleId() { + $this->_html = $this->_helper->reseauxSociaux('article', 123456789); $this->assertContains('id/123456789', $this->_html); } + + + /** @test */ + public function onInexistantNoticeLinkShouldBeEmpty() { + $this->_html = $this->_helper->reseauxSociaux('notice', 1234567891234); + $this->assertEmpty($this->_html); + } } + ?> \ No newline at end of file