From 73d2c06d843f608665229d94ed073607f049035c Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Sat, 13 Jul 2013 12:09:13 +0000
Subject: [PATCH] =?UTF-8?q?Sur=20kiosque=20Mur=20/=20Panier:=20le=20retour?=
 =?UTF-8?q?=20=C3=A0=20la=20liste=20renvoie=20vers=20le=20panier=20#9486?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 library/ZendAfi/View/Helper/UrlNotice.php     | 19 +++---
 .../View/Helper/Accueil/KiosqueMurTest.php    | 59 +++++++++++++------
 2 files changed, 49 insertions(+), 29 deletions(-)

diff --git a/library/ZendAfi/View/Helper/UrlNotice.php b/library/ZendAfi/View/Helper/UrlNotice.php
index 9cad2f58f5a..07f39425e82 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 969d213e34e..c9a5d7c8fc3 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
-- 
GitLab