From d204b6e016d6fd391b34762d64cbbb8903bfe324 Mon Sep 17 00:00:00 2001 From: Ghislain Loas <ghislo@sandbox.pergame.net> Date: Wed, 20 May 2015 15:32:06 +0200 Subject: [PATCH] hotline #25054 calendar no event with only location filter --- ...alendar_no_event_with_only_location_filter | 1 + .../opac/controllers/CmsController.php | 4 +- .../CmsControllerCalendarActionTest.php | 75 ++++++++++++++----- 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 VERSIONS_HOTLINE/#25054_calendar_no_event_with_only_location_filter diff --git a/VERSIONS_HOTLINE/#25054_calendar_no_event_with_only_location_filter b/VERSIONS_HOTLINE/#25054_calendar_no_event_with_only_location_filter new file mode 100644 index 00000000000..fd2ca88338f --- /dev/null +++ b/VERSIONS_HOTLINE/#25054_calendar_no_event_with_only_location_filter @@ -0,0 +1 @@ + - ticket #25054 : Correction du filtrage du calendrier lorsque la date n'était pas sélectionnée. \ No newline at end of file diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index fd1d2083da8..36bf4fa0ef4 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -258,8 +258,9 @@ class CmsController extends Zend_Controller_Action { $preferences = array_merge($module_calendrier->getDefaultValues(), $this->_modulesPreferences($id_module)); + if (!preg_match('/[0-9]{4}-[0-9]{2}/', $date)) { - $date = date('Y-m-d'); + $date = null; } // param pour l'affichage du calendar @@ -267,6 +268,7 @@ class CmsController extends Zend_Controller_Action { if ($month = $this->_getParam('month')) { $param['DATE'] = date('Y') . '-' . sprintf("%02d", $month); } + $param['URL']=''; $param['ID_BIB']=Class_Profil::getCurrentProfil()->getIdSite(); $param['AFFICH_MOIS']=1; diff --git a/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php b/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php index b49997b1ee7..cbad7943c75 100644 --- a/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerCalendarActionTest.php @@ -18,6 +18,8 @@ * along with BOKEH; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + + abstract class CmsControllerCalendarActionTestCase extends AbstractControllerTestCase { protected $_nanook2; @@ -348,33 +350,35 @@ class CmsControllerCalendarActionWithDayTest extends AbstractControllerTestCase } } + + class CmsControllerCalendarActionHeaderTest extends AbstractControllerTestCase { public function setUp() { parent::setUp(); $this->cfg_accueil = [ - 'modules' => [ - '1' => [ - 'division' => '1', - 'type_module' => 'CALENDAR', - 'preferences' => [ - 'titre' => 'Rendez-vous', - 'rss_avis' => false, - 'id_categorie' => '12-2', - 'display_cat_select' => true, - 'enabled_filters' => 'date;place;custom_field_2;zork', - 'display_event_info' => 'none' - ] - ] - ], - 'options' => [] + 'modules' => [ + '1' => [ + 'division' => '1', + 'type_module' => 'CALENDAR', + 'preferences' => [ + 'titre' => 'Rendez-vous', + 'rss_avis' => false, + 'id_categorie' => '12-2', + 'display_cat_select' => true, + 'enabled_filters' => 'date;place;custom_field_2;zork', + 'display_event_info' => 'none' + ] + ] + ], + 'options' => [] ]; $this->fixture('Class_Profil', - ['id' => 3, - 'browser' => 'opac', - 'libelle' => 'Rendez-vous', - 'cfg_accueil' => $this->cfg_accueil]); + ['id' => 3, + 'browser' => 'opac', + 'libelle' => 'Rendez-vous', + 'cfg_accueil' => $this->cfg_accueil]); $this->dispatch('/index/index/id_profil/3'); } @@ -387,4 +391,35 @@ class CmsControllerCalendarActionHeaderTest extends AbstractControllerTestCase { } } -?> \ No newline at end of file + + + +class CmsControllerCalendarActionWithOutDateTest extends CmsControllerCalendarActionTestCase { + public function setUp() { + parent::setUp(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') + ->whenCalled('getArticlesByPreferences') + ->with(['display_order' => 'EventDebut', + 'id_categorie' => 2, + 'events_only' => true, + 'event_date' => '2015-05', + 'id_bib' => 0, + 'id_lieu' => '', + 'custom_fields' => [], + 'published' => true, + 'event_end_after' => '2015-05-20']) + ->answers([$this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'Kitchen', + 'contenu' => 'Cook'])]); + + $this->dispatch('/cms/calendar/id_profil/3/id_module/1/select_id_categorie/2/render/ajax', true); + } + + + /** @test */ + public function nextEventShouldBeCall() { + $this->assertXPathContentContains('//div', 'Kitchen', $this->_response->getBody()); + } +} -- GitLab