From 1b86cdc762266725d0224359108bcee9c56b0809 Mon Sep 17 00:00:00 2001
From: llaffont <laurent.laffont@gmail.com>
Date: Sat, 8 Feb 2014 10:30:12 +0100
Subject: [PATCH] Add tests for menu fix of commit 7287b2d

---
 .../View/Helper/Accueil/MenuVertical.php      |  2 +-
 .../View/Helper/Accueil/MenuVerticalTest.php  | 32 ++++++++++++-------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php
index 2ebe48f4fe4..ca98e79cf86 100644
--- a/library/ZendAfi/View/Helper/Accueil/MenuVertical.php
+++ b/library/ZendAfi/View/Helper/Accueil/MenuVertical.php
@@ -48,7 +48,7 @@ class ZendAfi_View_Helper_Accueil_MenuVertical extends ZendAfi_View_Helper_Accue
 			: [Class_Profil::getCurrentProfil()->getId(), $menu];
 
 		if (!$profil = Class_profil::find($id_profil))
-      $profil = Class_Profil::getCurrentProfil();
+			return $this->retourErreur($this->translate()->_('Ce menu ne contient aucune entrée.'));
 
 		$this->_cls_menu = new Class_Systeme_ModulesMenu();
 		$this->_li_style = sprintf('style="margin-left:20px;%s"',
diff --git a/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php b/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php
index 93a69d72ba5..a9ccb911a77 100644
--- a/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php
+++ b/tests/library/ZendAfi/View/Helper/Accueil/MenuVerticalTest.php
@@ -477,17 +477,19 @@ class MenuVerticalWithMenuFromOtherProfilTest extends ViewHelperTestCase {
 		parent::setUp();
 
 
-		Class_Profil::newInstanceWithId(28, ['cfg_menus' => [
-				'9' => ['libelle' => 'Menu vertical',
-								'menus' => [
-									['type_menu' => 'RSS',
-									 'libelle' => 'Flux',
-									 'picto' => 'vide.gif',
-									 'preferences' => ['id_items' => 2,
-																		 'id_categorie' => '',
-																		 'nb' => 5]]]
-					]
-				]]);
+		$this->fixture('Class_Profil',
+									 ['id' => 28,
+										'cfg_menus' => [
+											'9' => ['libelle' => 'Menu vertical',
+															'menus' => [
+																['type_menu' => 'RSS',
+																 'libelle' => 'Flux',
+																 'picto' => 'vide.gif',
+																 'preferences' => ['id_items' => 2,
+																									 'id_categorie' => '',
+																									 'nb' => 5]]]
+												]
+											]]);
 
 
 		$this->helper = new ZendAfi_View_Helper_Accueil_MenuVertical(12, [
@@ -505,6 +507,14 @@ class MenuVerticalWithMenuFromOtherProfilTest extends ViewHelperTestCase {
 	public function menuShouldContainsLinkToRss() {
 		$this->assertXPathContentContains($this->_html, '//ul/li/a', 'Flux');
 	}
+
+
+	/** @test */
+	public function whenProfilIsDeletedMenuShouldBeDislayErrorMessage() {
+		Class_Profil::deleteBy(['id_profil' => 28]);
+		$this->assertContains('Ce menu ne contient aucune entrée',
+													$this->helper->getBoite());
+	}
 }
 
 
-- 
GitLab