From 5b5e94d4760a5ddc7f5cebd13cbdb2059df02810 Mon Sep 17 00:00:00 2001
From: llaffont <llaffont@git-test.afi-sa.fr>
Date: Mon, 11 Jun 2012 09:33:23 +0000
Subject: [PATCH] =?UTF-8?q?Correction=20affichage=20des=20prochains=20e?=
 =?UTF-8?q?=CC=81ve=CC=80nements=20calendrier?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../ZendAfi/View/Helper/Accueil/Calendar.php  |  2 +-
 .../View/Helper/Accueil/CalendarTest.php      | 42 +++++++++++++++++++
 .../View/Helper/ViewHelperTestCase.php        |  7 ++++
 3 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/library/ZendAfi/View/Helper/Accueil/Calendar.php b/library/ZendAfi/View/Helper/Accueil/Calendar.php
index 22404cd38d1..d57ac8c4920 100644
--- a/library/ZendAfi/View/Helper/Accueil/Calendar.php
+++ b/library/ZendAfi/View/Helper/Accueil/Calendar.php
@@ -79,7 +79,7 @@ SCRIPT;
 					$param["DATE"] = $this->preferences['display_date'];
 		$param["URL"]="";
 		$param["ID_BIB"]=Class_Profil::getCurrentProfil()->getIdSite();
-		$param["NB_NEWS"]=3;
+		$param["NB_NEWS"]=(int)$this->preferences["nb_events"];
 		$param["ID_MODULE"] = $this->id_module;
 		$param["ID_CAT"] = $this->preferences["id_categorie"];
 		$param["SELECT_ID_CAT"] = array_isset("select_id_categorie", $this->preferences) ? $this->preferences["select_id_categorie"] : "all";
diff --git a/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php b/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php
index 71c8c3d6673..01f792bf1f1 100644
--- a/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php
+++ b/tests/library/ZendAfi/View/Helper/Accueil/CalendarTest.php
@@ -196,6 +196,48 @@ class CalendarWithEmptyPreferencesTest extends CalendarWithEmptyPreferencesTestC
 }
 
 
+
+
+class CalendarWithPreferencesNbEventsOneTest extends CalendarWithEmptyPreferencesTestCase {
+	public function setUp() {
+		parent::setUp();
+
+		$article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
+			->whenCalled('getArticlesByPreferences')
+			->with(array(
+									 'display_order' => 'EventDebut',
+									 'id_categorie' => '',
+									 'event_date' => strftime('%Y-%m'),
+									 'events_only' => true,
+									 'published' => false))
+			->answers(array($this->nanook2, $this->opac4, $this->amber))
+			->getWrapper()
+			->beStrict();
+
+
+		$params = array('division' => '1',
+										'type_module' => 'CALENDAR',
+										'preferences' => array('titre' => 'Calendrier',
+																					 'rss_avis' => '0',
+																					 'id_categorie' => '',
+																					 'nb_events' => 1));
+		$this->helper = new ZendAfi_View_Helper_Accueil_Calendar(2, $params);
+
+		$this->html = $this->helper->getBoite();
+	}
+
+
+	/** @test */
+	function calendarEventListShouldContainsOneArticle() {
+		$this->assertXPathCount($this->html,
+														'//a[@class="calendar_event_title"][contains(@href, "cms/articleview")]',
+														1);
+	}
+}
+
+
+
+
 class CalendarWithEmptyParamsLocaleEnAndOnlyTwoArticlesReturned Extends CalendarWithEmptyPreferencesTestCase {
 	public function setUp() {
 		parent::setUp();
diff --git a/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php b/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php
index 252c3ed61bc..beb7d07ee67 100644
--- a/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php
+++ b/tests/library/ZendAfi/View/Helper/ViewHelperTestCase.php
@@ -39,6 +39,13 @@ abstract class ViewHelperTestCase extends PHPUnit_Framework_TestCase {
 	}
 
 
+	public function assertXpathCount() {
+		call_user_func_array(array(new Storm_Test_XPath(), __FUNCTION__), 
+												 func_get_args());
+
+	}
+
+
 	public function assertNotXpath() {
 		call_user_func_array(array(new Storm_Test_XPath(), __FUNCTION__), 
 												 func_get_args());
-- 
GitLab