From 91bd4c411e04ef2a7f50ba3714f05fcf4184fe89 Mon Sep 17 00:00:00 2001
From: gloas <gloas@git-test.afi-sa.fr>
Date: Thu, 11 Jul 2013 15:58:06 +0000
Subject: [PATCH] Menu module: ajout menu type reseau sociaux + tests

---
 .gitattributes                                |   1 +
 library/Class/Systeme/ModulesMenu.php         |   7 +-
 .../Systeme/ModulesMenu/ReseauxSociaux.php    |  36 ++++++
 .../admin/controllers/MenusControllerTest.php | 114 +++++++++++++++++-
 4 files changed, 153 insertions(+), 5 deletions(-)
 create mode 100644 library/Class/Systeme/ModulesMenu/ReseauxSociaux.php

diff --git a/.gitattributes b/.gitattributes
index 5dfe711d931..38f61995415 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2413,6 +2413,7 @@ library/Class/Systeme/ModulesMenu/RechercheGeographique.php -text
 library/Class/Systeme/ModulesMenu/RechercheGuidee.php -text
 library/Class/Systeme/ModulesMenu/RechercheOai.php -text
 library/Class/Systeme/ModulesMenu/RechercheSimple.php -text
+library/Class/Systeme/ModulesMenu/ReseauxSociaux.php -text
 library/Class/Systeme/ModulesMenu/ReserverPoste.php -text
 library/Class/Systeme/ModulesMenu/Rss.php -text
 library/Class/Systeme/ModulesMenu/Sitotheque.php -text
diff --git a/library/Class/Systeme/ModulesMenu.php b/library/Class/Systeme/ModulesMenu.php
index 3189bc8f5e0..7d3ff2f5bb6 100644
--- a/library/Class/Systeme/ModulesMenu.php
+++ b/library/Class/Systeme/ModulesMenu.php
@@ -31,6 +31,7 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
 	const GROUP_MENU_RECHERCHES = 'MENU_RECH';
 	const GROUP_MENU_CATALOGUES = 'MENU_CATALOG';
 	const GROUP_MENU_ABONNES = 'MENU_ABONNE';
+	const GROUP_MENU_PARTAGER = 'MENU_PARTAGER';
 
 	const MODULE_ACCUEIL_PREFIX = 'MODULE_ACCUEIL_';
 
@@ -41,7 +42,8 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
 		self::GROUP_MENU_INFORMATIONS => "Informations",
 		self::GROUP_MENU_RECHERCHES =>"Recherches" ,
 		self::GROUP_MENU_CATALOGUES => "Catalogues",
-		self::GROUP_MENU_ABONNES	=> "Abonnés"
+		self::GROUP_MENU_ABONNES	=> "Abonnés",
+		self::GROUP_MENU_PARTAGER => "Partager"
 	];
 
 	private $fonctions;
@@ -122,7 +124,8 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract {
 			"NUMILOG" => new Class_Systeme_ModulesMenu_Numilog(),
 			"ARTEVOD" => new Class_Systeme_ModulesMenu_ArteVod(),
 			"RESERVER_POSTE" => new Class_Systeme_ModulesMenu_ReserverPoste(),
-			'SUGGESTION_ACHAT' => new Class_Systeme_ModulesMenu_SuggestionAchat()
+			'SUGGESTION_ACHAT' => new Class_Systeme_ModulesMenu_SuggestionAchat(),
+			'RESEAUX_SOCIAUX' => new Class_Systeme_ModulesMenu_ReseauxSociaux()
 		];
 
 		if (!Class_AdminVar::isMenuBoiteEnabled())
diff --git a/library/Class/Systeme/ModulesMenu/ReseauxSociaux.php b/library/Class/Systeme/ModulesMenu/ReseauxSociaux.php
new file mode 100644
index 00000000000..ab43e3ae472
--- /dev/null
+++ b/library/Class/Systeme/ModulesMenu/ReseauxSociaux.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+
+
+class Class_Systeme_ModulesMenu_ReseauxSociaux extends Class_Systeme_ModulesMenu_Null {
+	/** @var string */
+	protected $_group = Class_Systeme_ModulesMenu::GROUP_MENU_PARTAGER;
+
+	/** @var string */
+	protected $_type_module = 'ReseauxSociaux';
+
+	/** @var string */
+	protected $_libelle = 'Reseaux sociaux';
+
+	protected $_url='/#';
+}
+
+?>
\ No newline at end of file
diff --git a/tests/application/modules/admin/controllers/MenusControllerTest.php b/tests/application/modules/admin/controllers/MenusControllerTest.php
index a45eb31e4dc..f95e6e92ff4 100644
--- a/tests/application/modules/admin/controllers/MenusControllerTest.php
+++ b/tests/application/modules/admin/controllers/MenusControllerTest.php
@@ -67,9 +67,26 @@ abstract class Admin_MenusControllerProfilJazzTestCase extends Admin_AbstractCon
 																			['type_menu' => 'CATALOGUE',
 																			 'libelle' => 'Libelle du catalogue',
 																			 'preferences' => ['titre' => 'Titre du catalogue'],
-																			 'picto' => 'vide.gif' ]
-																			
-													],
+																			 'picto' => 'vide.gif' ],
+																			['type_menu' => 'RESEAUX_SOCIAUX',
+																			 'libelle' => 'Suivez nous sur les réseaux sociaux',
+																			 'picto' => 'vide.gif'],
+																			['type_menu' => 'URL',
+																			 'libelle' => '',
+																			 'picto' => 'facebook.png',
+																			 'preferences' => ['url' => 'http://www.facebook.com',
+																												 'target' => 1]],
+																			['type_menu' => 'URL',
+																			 'libelle' => '',
+																			 'picto' => 'twitter.png',
+																			 'preferences' => ['url' => 'http://www.twitter.com',
+																												 'target' => 1]],
+																			['type_menu' => 'URL',
+																			 'libelle' => '',
+																			 'picto' => 'google.png',
+																			 'preferences' => ['url' => 'http://www.google.com',
+																												 'target' => 0]]
+														],
     		],
 
 									'V' => ['libelle' => 'Menu vertical',
@@ -352,4 +369,95 @@ class Admin_MenusControllerProfilJazzEditCatalogueActionTest extends Admin_Menus
 	}
 }
 
+class Admin_MenusControllerProfilJazzResauSociauxActionTest extends Admin_MenusControllerProfilJazzTestCase {
+	public function setUp() {
+		parent::setUp();	
+		
+		$this->dispatch('admin/menus/index?=5'.
+										http_build_query(array('id_profil' => '5',
+																					 'id_bib' => 'null',
+																					 'type_menu' => 'RESEAUX_SOCIAUX',
+																					 'id_module' => 1,
+																					 'libelle' => 'Suivez nous sur les réseaux sociaux',
+																					 'picto' => 'vide.gif')));
+	}
+
+
+	/** @test */
+	public function libellePratiqueShouldBeDisplayed() {
+		$this->assertXPath("//input[@name='libelle'][@value='Suivez nous sur les réseaux sociaux']",$this->_response->getBody());
+	}
+
+
+	/** @test */
+	function profilTranslaterShouldBeNullTranslator() {
+		$this->assertInstanceOf('Class_Profil_NullTranslator', Class_Profil::getCurrentProfil()->getTranslator());
+	}
+}
+
+class Admin_MenusControllerProfilJazzFacebookActionTest extends Admin_MenusControllerProfilJazzTestCase {
+	public function setUp() {
+		parent::setUp();	
+		
+		$this->dispatch('admin/menus/index?=5'.
+										http_build_query(array('id_profil' => '5',
+																					 'id_bib' => 'null',
+																					 'type_menu' => 'URL',
+																					 'id_module' => 1,
+																					 'libelle' => '',
+																					 'picto' => 'facebook.png',
+																					 'preferences' => 'url=http://www.facebook.com|target=1')));
+	}
+
+
+	/** @test */
+	public function facebookIconShouldBeDisplayed() {
+		$this->assertXPath("//img[contains(@src, 'facebook.png')]", $this->_response->getBody());
+	}
+}
+
+class Admin_MenusControllerProfilJazzTwitterActionTest extends Admin_MenusControllerProfilJazzTestCase {
+	public function setUp() {
+		parent::setUp();	
+		
+		$this->dispatch('admin/menus/index?=5'.
+										http_build_query(array('id_profil' => '5',
+																					 'id_bib' => 'null',
+																					 'type_menu' => 'URL',
+																					 'id_module' => 3,
+																					 'libelle' => '',
+																					 'picto' => 'twitter.png',
+																					 'preferences' => 'url=http://www.twitter.com|target=1')));
+	}
+
+
+
+	/** @test */
+	public function twitterIconShouldBeDisplayed() {
+		$this->assertXPath("//img[contains(@src, 'twitter.png')]");
+	}
+}
+
+
+class Admin_MenusControllerProfilJazzGoogleActionTest extends Admin_MenusControllerProfilJazzTestCase {
+	public function setUp() {
+		parent::setUp();	
+		
+		$this->dispatch('admin/menus/index?=5'.
+										http_build_query(array('id_profil' => '5',
+																					 'id_bib' => 'null',
+																					 'type_menu' => 'URL',
+																					 'id_module' => 1,
+																					 'libelle' => '',
+																					 'picto' => 'google.png',
+																					 'preferences' =>'url=http://www.google.com|target=1')));
+	}
+
+
+/** @test */
+	public function googleIconShouldBeDisplayed() {
+		$this->assertXPath("//img[contains(@src, 'google.png')]");
+	}
+}
+
 ?>
\ No newline at end of file
-- 
GitLab