Skip to content
Snippets Groups Projects
Commit dd5f208b authored by efalcy's avatar efalcy
Browse files

Menu Vertical : ajout d'un class profil_selected

parent 917e4f61
Branches
Tags
No related merge requests found
......@@ -39,7 +39,7 @@ class Class_Systeme_ModulesMenu_Profil extends Class_Systeme_ModulesMenu_Null{
protected $_defaultValues = array('clef_profil' => '1');// Par defaut profil portail
public function getUrl($preferences=[]) {
return $this->_url = BASE_URL . "/opac?id_profil=" . $preferences["clef_profil"];
return $this->_url = BASE_URL . "/opac/index/index/id_profil/" . $preferences["clef_profil"];
}
}
......
......@@ -182,6 +182,40 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
}
/**
* @param array $menuitem
* @return string
*/
private function _menuPROFILBuilder($menuitem) {
$preferences = isset($menuitem["preferences"]) ? $menuitem["preferences"] : null;
$param_url = $this->_cls_menu->getUrl('PROFIL', $preferences);
$url = $param_url["url"];
$target = ($param_url["target"] > "") ? $param_url["target"] : null;
$a_href = $url ? "href='".htmlspecialchars($url)."'" : "";
$a_target = $target ? "target='$target'" : "";
$class = (Class_Profil::getCurrentProfil()->getId() == (int)$preferences['clef_profil'])
? 'menuGauche selected_profil'
: 'menuGauche';
$content ='<li class="'.$class.'">';
if ($menuitem["picto"] > '' and $menuitem["picto"] != "vide.gif")
$content.= sprintf('<img alt="%s" src="%s" />',
$this->translate()->_('pictogramme pour %s',
$menuitem["libelle"]),
$this->path_ico.$menuitem["picto"]);
$content .=
'<a '.$a_href.' '.$a_target.' >'.
htmlspecialchars($menuitem["libelle"]).
'</a>';
$content .= '</li>';
return $content;
}
/**
* @param array $menuitem
* @return string
......
......@@ -376,7 +376,12 @@ class MenuVerticalAlbumTest extends MenuVerticalTestCase {
class MenuVerticalWithMenuTest extends MenuVerticalTestCase {
protected function _menuConfigTrigger() {
Class_Profil::getCurrentProfil()->setCfgMenus(
$profil_adulte = $this->fixture('Class_Profil', ['id' => 4]);
$profil_jeunesse = $this->fixture('Class_Profil', ['id' => 8]);
Class_Profil::setCurrentProfil($profil_adulte);
$profil_adulte->setCfgMenus(
[
7 => ['libelle' => 'Menu vertical',
'menus' => [
......@@ -392,12 +397,20 @@ class MenuVerticalWithMenuTest extends MenuVerticalTestCase {
'id_categorie' => '',
'id_items' => '46',
'nb' => '10' ]]
]
],
]
]
]
);
]],
['libelle' => 'Profil adulte',
'type_menu' => 'PROFIL',
'picto' => 'vide.gif',
'preferences' => ['clef_profil' => '4']],
['libelle' => 'Profil jeunesse',
'type_menu' => 'PROFIL',
'picto' => 'vide.gif',
'preferences' => ['clef_profil' => '8']],
]]]
);
}
......@@ -405,6 +418,22 @@ class MenuVerticalWithMenuTest extends MenuVerticalTestCase {
public function menuLinkShouldBeSharp() {
$this->assertXPathContentContains($this->_html, '//ul/li/a[@href="#"]', 'Menu');
}
/** @test */
public function menuForProfilAdulteShouldHaveUrlIdProfilFourSelected() {
$this->assertXPathContentContains($this->_html,
'//ul/li[contains(@class, "selected_profil")]/a[contains(@href, "/id_profil/4")]',
'Profil adulte');
}
/** @test */
public function menuForProfilJeunesseShouldHaveUrlIdProfilHeightNotSelected() {
$this->assertXPathContentContains($this->_html,
'//ul/li[not(contains(@class, "selected_profil"))]/a[contains(@href, "/id_profil/8")]',
'Profil jeunesse');
}
}
......
......@@ -19,6 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
abstract class ViewHelperTestCase extends PHPUnit_Framework_TestCase {
use Storm_Test_THelpers;
public function assertQueryContentContains() {
call_user_func_array(array(new Storm_Test_XPath(), __FUNCTION__),
func_get_args());
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment