diff --git a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php index 2f10fb0a3e58af384c203f641b83162cd0b73777..89326f208a30f391bd1b08336f5f93ca1d0bdb0e 100644 --- a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php +++ b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php @@ -196,10 +196,7 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue $a_href = $url ? "href='".htmlspecialchars($url)."'" : ""; $a_target = $target ? "target='$target'" : ""; - $class = (Class_Profil::getCurrentProfil()->getId() == (int)$preferences['clef_profil']) - ? 'menuGauche selected_profil' - : 'menuGauche'; - + $class = $this->_getContextClass(isset($menuitem["preferences"]["clef_profil"]) ? (int) $menuitem["preferences"]['clef_profil'] : '0'); $content ='<li class="'.$class.'">'; if ($menuitem["picto"] > '' and $menuitem["picto"] != "vide.gif") $content.= sprintf('<img alt="%s" src="%s" />', @@ -308,7 +305,7 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue $a_href = $url ? 'href="'.htmlspecialchars($url).'"':''; $a_target = $target ? "target='$target'" : ""; - $content ='<li class="menuGauche">'; + $content ='<li class="'.$this->_getContextClass(isset($menuitem["preferences"]["clef_profil"]) ? (int) $menuitem["preferences"]['clef_profil'] : '0').'">'; if ($menuitem["picto"] > '' and $menuitem["picto"] != "vide.gif") $content.= sprintf('<img alt="%s" src="%s" />', $this->translate()->_('pictogramme pour %s', @@ -343,4 +340,12 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue return $this->_renderListItem($menuitem, $param_url["url"], $target); } + + + protected function _getContextClass($id_profil) { + return (Class_Profil::getCurrentProfil()->getId() == $id_profil) + ? 'menuGauche selected_profil' + : 'menuGauche'; + + } } \ No newline at end of file diff --git a/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php b/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php index 3a217ada4257ae47a3712e2f591c97f8dba40935..93a69d72ba59473cfb557fe2208708e1a0b53900 100644 --- a/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php +++ b/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php @@ -593,7 +593,7 @@ class MenuVerticalWithMenuAsLinkToProfilTest extends MenuVerticalTestCase { 'type_menu' => 'MENU', 'libelle' => 'Menu', 'picto' => 'vide.gif', - 'preferences' => ['clef_profil' => '8'], + 'preferences' => ['clef_profil' => '4'], 'sous_menus' => [['type_menu' => 'RSS', 'libelle' => 'Bulletin electronique', 'picto' => 'vide.gif', @@ -603,11 +603,6 @@ class MenuVerticalWithMenuAsLinkToProfilTest extends MenuVerticalTestCase { 'nb' => '10' ]] ]], - ['libelle' => 'Profil adulte', - 'type_menu' => 'PROFIL', - 'picto' => 'vide.gif', - 'preferences' => ['clef_profil' => '4']], - ['libelle' => 'Profil jeunesse', 'type_menu' => 'PROFIL', 'picto' => 'vide.gif', @@ -620,13 +615,22 @@ class MenuVerticalWithMenuAsLinkToProfilTest extends MenuVerticalTestCase { /** @test */ public function menuShouldLinkToProfil8() { - $this->assertXPathContentContains($this->_html, '//ul/li/a[contains(@href,"opac/index/index/id_profil/8")]', 'Menu'); + $this->assertXPathContentContains($this->_html, '//ul/li/a[contains(@href,"opac/index/index/id_profil/4")]', 'Menu'); + } + + + /** @test */ + public function menuForProfilAdulteShouldHaveUrlIdProfilHeightSelected() { + $this->assertXPathContentContains($this->_html, + '//ul/li[contains(@class, "selected_profil")]/a[contains(@href, "/id_profil/4")]', + 'Menu'); } + /** @test */ public function menuLinkToProfilShouldNotContainsOnclik() { - $this->assertNotXPath($this->_html, '//ul/li/a[contains(@href,"opac/index/index/id_profil/8")][@onclic="afficher_sous_menu();"]'); + $this->assertNotXPath($this->_html, '//ul/li/a[@onclic="afficher_sous_menu();"]'); } }