diff --git a/library/ZendAfi/View/Helper/UrlNotice.php b/library/ZendAfi/View/Helper/UrlNotice.php index 9cad2f58f5aca1be889a001e76625e6b17f11b18..07f39425e82e7aaf588e36dd731be98d5e317665 100644 --- a/library/ZendAfi/View/Helper/UrlNotice.php +++ b/library/ZendAfi/View/Helper/UrlNotice.php @@ -65,18 +65,15 @@ class ZendAfi_View_Helper_UrlNotice extends Zend_View_Helper_HtmlElement { } } else { - $options = ['controller' => 'recherche', - 'action' => 'viewnotice', - 'clef' => $notice->getClefAlpha(), - 'id' => $notice->getId()]; - - - if (array_isset('retour_panier', $preferences)) - $options['retour_panier'] = $preferences['retour_panier']; - - if (array_isset('id_catalogue', $preferences)) - $options['id_catalogue'] = $preferences['id_catalogue']; + $options = array_merge(['controller' => 'recherche', + 'action' => 'viewnotice', + 'clef' => $notice->getClefAlpha(), + 'id' => $notice->getId()], + array_intersect_key(array_filter($preferences), + ['retour_panier' => '', + 'id_panier' => 0, + 'id_catalogue' => 0])); } return $this->view->url($options); diff --git a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueMurTest.php b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueMurTest.php index 969d213e34ef04d3e72e38d370fe8bde59fab47f..c9a5d7c8fc3fa5342f63f17ebca27669d5e1882e 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/KiosqueMurTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/KiosqueMurTest.php @@ -28,25 +28,7 @@ abstract class ZendAfi_View_Helper_Accueil_KiosqueMurTestCase extends ViewHelper defineConstant("PATH_SKIN", "./public/opac/skins/original/"); $this->_helper = new ZendAfi_View_Helper_Accueil_Kiosque(3, $this->getPreferences()); $this->_helper->setView(new ZendAfi_Controller_Action_Helper_View()); - } - - - public function getPreferences() { - return ['type_module' => 'KIOSQUE', - 'division' => 3, - 'preferences' => array_merge(['style_liste' => 'mur'], - $this->getExtraPreferences())]; - } - - - abstract public function getExtraPreferences(); -} - - -class ZendAfi_View_Helper_Accueil_KiosqueMurWithCatalogueTest extends ZendAfi_View_Helper_Accueil_KiosqueMurTestCase { - public function setUp() { - parent::setUp(); $notices = [Class_Notice::newInstanceWithId(2, ['unimarc' => "00627nam0 22002291 450 00100080000001000180000802100070002610000410003310100130007410500390008720000690012621000360019521500290023122500230026067600060028368600100028970000290029983000270032883500060035593000140036193200220037500028922 a2-07-052818-9 aFR a20010130 d 0frea01 ba1 afreceng 1[2001-01-30-00.00.00.000000][][][]1 aHarry Potter et le prisonnier d'AzkabanfJoanne Kathleen Rowling aPariscGallimard jeunessed2000 a465 p.3465cill.d18 cm 2aFolio juniorv1006 10 aR ROW1 aRowlingbJoanne Kathleen 1A32A partir de 10 ans aJ aRomans4R aSorcier-Sorcière", @@ -73,6 +55,21 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithCatalogueTest extends ZendAfi_Vi } + public function getPreferences() { + return ['type_module' => 'KIOSQUE', + 'division' => 3, + 'preferences' => array_merge(['style_liste' => 'mur'], + $this->getExtraPreferences())]; + } + + + abstract public function getExtraPreferences(); +} + + + + +class ZendAfi_View_Helper_Accueil_KiosqueMurWithCatalogueTest extends ZendAfi_View_Helper_Accueil_KiosqueMurTestCase { public function getExtraPreferences() { return ['id_catalogue' => 12]; } @@ -96,4 +93,30 @@ class ZendAfi_View_Helper_Accueil_KiosqueMurWithCatalogueTest extends ZendAfi_Vi } + + +class ZendAfi_View_Helper_Accueil_KiosqueMurWithPanierTest extends ZendAfi_View_Helper_Accueil_KiosqueMurTestCase { + public function getExtraPreferences() { + return ['id_panier' => 15]; + } + + + + /** @test */ + public function firstNoticeTitleShouldLinkToNotice2WithIdPanier15() { + $this->assertXPath($this->_html, + '//div[@class="notice"]//span/a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/id_panier/15")]', + $this->_html); + } + + + /** @test */ + public function firstNoticeImgShouldLinkToNotice2WithIdPanier15() { + $this->assertXPath($this->_html, + '//div[@class="notice"]//a[contains(@href, "recherche/viewnotice/clef/POTTER/id/2/id_panier/15")]//img', + $this->_html); + } +} + + ?> \ No newline at end of file