From 36b7b101966124142a7b6b4887dd3e7ff0c3d310 Mon Sep 17 00:00:00 2001
From: Ghislain Loas <ghislo@sandbox.pergame.net>
Date: Wed, 1 Oct 2014 16:19:06 +0200
Subject: [PATCH] fix test setup

---
 .../CmsControllerCalendarActionTest.php       | 61 +++++++------------
 1 file changed, 23 insertions(+), 38 deletions(-)

diff --git a/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php b/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php
index 1fddada33d2..ac31275605f 100644
--- a/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php
+++ b/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php
@@ -36,9 +36,7 @@ abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTes
 																	 'id_categorie' => '12-2',
 																	 'display_cat_select' => true,
 																	 'enabled_filters' => 'date;place;custom_field_2;zork',
-																	 'display_event_info' => 'none',
-																	 'mode-affichage' => 'article',
-																	 'display_full_page' => false]]],
+																	 'display_event_info' => 'none']]],
 			 'options' => 	[]];
 
 
@@ -229,10 +227,26 @@ class CmsControllerCalendarActionWithFiltersTest extends CmsControllerCalendarAc
 
 
 
-class CmsControllerCalendarActionWithDayTest extends CmsControllerCalendarActionTestCase {
+class CmsControllerCalendarActionWithDayTest extends AbstractControllerTestCase {
 	public function setUp() {
 		parent::setUp();
 
+		$cfg_accueil = ['modules' =>
+										[ '1' => [
+															'division' => '1',
+															'type_module' => 'CALENDAR',
+															'preferences' => ['mode-affichage' => 'article',
+																								'display_full_page' => 0]]],
+										'options' => 	[]];
+
+
+		$this->fixture('Class_Profil',
+									 ['id' => 3,
+										'browser' => 'opac',
+										'libelle' => 'Plop',
+										'cfg_accueil' => $cfg_accueil]);
+
+
 		$this->fixture('Class_Article',
 									 ['id' => 5,
 										'titre' => 'News of the 15th September',
@@ -251,7 +265,7 @@ class CmsControllerCalendarActionWithDayTest extends CmsControllerCalendarAction
 		ZendAfi_View_Helper_CalendarContent::setTimeSource($time_source);
 		ZendAfi_View_Helper_Calendar_Table::setTimeSource($time_source);
 
-		Class_Article::getLoader()
+		Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article')
 			->whenCalled('getArticlesByPreferences')
 			->with(['display_order' => 'EventDebut',
 							'id_categorie' => '',
@@ -291,45 +305,16 @@ class CmsControllerCalendarActionWithDayTest extends CmsControllerCalendarAction
 
 			->whenCalled('getArticlesByPreferences')
 			->with(['display_order' => 'EventDebut',
-							'id_categorie' => '12-2',
+							'id_categorie' => '',
 							'events_only' => true,
-							'event_date' => '2014-09',
+							'event_date' => '2014-09-30',
 							'id_bib' => 0,
 							'id_lieu' => '',
 							'custom_fields' => [],
 							'published' => true])
-			->answers([Class_Article::find(2), Class_Article::find(5)])
-
-			->whenCalled('getArticlesByPreferences')
-			->with(['display_order' => 'EventDebut',
-							'id_categorie' => '12-2',
-							'events_only' => true,
-							'event_date' => '2014-09',
-							'id_bib' => 0,
-							'id_lieu' => '',
-							'custom_fields' => [],
-							'published' => true,
-							'event_end_after' => '2014-09-02'])
-			->answers([Class_Article::find(2), Class_Article::find(5)])
-
-			->whenCalled('getArticlesByPreferences')
-			->with(['display_order' => 'EventDebut',
-							'id_categorie' => '12-2',
-							'events_only' => true,
-							'event_date' => '',
-							'id_bib' => 0,
-							'id_lieu' => '',
-							'custom_fields' => [],
-							'published' => true,
-							'event_start_after' => '2014-09',
-							'event_end_after' => '',
-							'limit' => 3])
-			->answers([Class_Article::find(2), Class_Article::find(5)])
-
-
+			->answers([Class_Article::find(2)])
 			->beStrict();
 
-
 		$this->dispatch('cms/calendar/date/2014-09-30/id_profil/3/id_module/1/opac/render/ajax', true);
 	}
 
@@ -348,7 +333,7 @@ class CmsControllerCalendarActionWithDayTest extends CmsControllerCalendarAction
 
 	/** @test **/
 	public function newsOfThe15ThSeptemberEventShouldNotBPresent() {
-		$this->assertNotXPathContentContains('//div[@class="calendar"]//article//header', 'News of the 15th September');
+		$this->assertNotXPathContentContains('//div[@id="boite_1"][@class="calendar"]//article//header', 'News of the 15th September', $this->_response->getBody());
 	}
 
 
-- 
GitLab