diff --git a/VERSIONS_HOTLINE/50953 b/VERSIONS_HOTLINE/50953 new file mode 100644 index 0000000000000000000000000000000000000000..a058d27f4aec99c1559449976562fb6e9b8c7c4c --- /dev/null +++ b/VERSIONS_HOTLINE/50953 @@ -0,0 +1 @@ + - ticket #50953 : Lien dans l'agenda vers un événement répétitif n'affiche pas l'événement \ No newline at end of file diff --git a/library/Class/Article.php b/library/Class/Article.php index 8b7f8cb90fae7af24658c81df6a77ebf3a948f97..c37c723444c415e63867d0f2a3fbabbaa4866e32 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -363,6 +363,8 @@ class ArticleLoader extends Storm_Model_Loader { Class_Article::getLoader()->findAll($select), $this->_custom_fields)); + + if ( ($this->_sort_order == 'Selection') or !$this->_nb_aff @@ -459,13 +461,14 @@ class ArticleLoader extends Storm_Model_Loader { public function filterByDay($day, $articles) { - $day_num = gmdate("w", $day); + $day_num = date("w", $day); return array_filter($articles, - function($event) { - $pick_day_as_array = $event->getPickDayAsArray(); - if(empty($pick_day_as_array) || in_array($day_num, $pick_day_as_array)) - return $event; - }); + function($event) use ($day_num) { + $pick_day_as_array = $event->getPickDayAsArray(); + if(empty($pick_day_as_array) || in_array($day_num, $pick_day_as_array)) + return $event; + }); + } diff --git a/tests/application/modules/admin/controllers/CmsControllerTest.php b/tests/application/modules/admin/controllers/CmsControllerTest.php index a06af8ddc041243a168d6d7a5e3ce500c58013fa..4e7921161b65aa4a2b29eaee61a59e0f42053824 100644 --- a/tests/application/modules/admin/controllers/CmsControllerTest.php +++ b/tests/application/modules/admin/controllers/CmsControllerTest.php @@ -199,7 +199,7 @@ abstract class CmsControllerTestCase extends Admin_AbstractControllerTestCase { 'date_creation' => '2010-12-25 10:23:23', 'date_maj' => '2010-12-26 11:12:34', 'domaine_ids' => [11,12], - 'pick_day' => 'monday', + 'pick_day' => '0', 'avis_users' => []]); $this->cat_evenements->setArticles([$this->concert]); diff --git a/tests/application/modules/opac/controllers/CmsControllerTest.php b/tests/application/modules/opac/controllers/CmsControllerTest.php index 65fbfb3faf087d134ee6672b469be47a24796500..9ab6507a95321c74b629eb4f5fe16dfd2e959fa7 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -270,85 +270,96 @@ abstract class AbstractCmsControllerArticleViewByDateTest extends AbstractContro protected $display_order = "EventDebut"; public function dispatchViewByDate() { - Class_Profil::getCurrentProfil() - ->setCfgAccueil( - ['modules' => - ['8' => ['division' => '0', - 'type_module' => 'CALENDAR', - 'preferences' => ['display_mode' => $this->display_mode, - 'display_order' => $this->display_order]], - 'options' =>[]]] + $this->fixturesForDispatch(); + + $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&id_profil=2&select_id_categorie=all', true); + } + + protected function fixturesForDispatch() { + Class_Profil::getCurrentProfil() + ->setCfgAccueil( + ['modules' => + ['8' => ['division' => '0', + 'type_module' => 'CALENDAR', + 'preferences' => ['display_mode' => $this->display_mode, + 'display_order' => $this->display_order]], + 'options' =>[]]] ); - Class_AdminVar::newInstanceWithId('WORKFLOW', ['valeur' => '']); + Class_AdminVar::newInstanceWithId('WORKFLOW', ['valeur' => '']); + $this->fixture('Class_ArticleCategorie', + ['id' => 1, + 'libelle' => 'Alimentaire', + 'bib'=> $this->fixture('Class_Bib', + ['id' => 1, + 'libelle' => 'Bonlieu' + ]) + ]); + $articles = [ + $this->fixture('Class_Article', + ['id' => 1, + 'titre' => 'La fête de la banane', + 'date_creation' => '2011-01-15', + 'contenu' => 'Pas qu\'à moitié {FIN} Une fête qui glisse !', + 'events_debut' => '2011-09-03', + 'events_fin' => '2011-10-03', + 'categorie' => Class_ArticleCategorie::find(1) + ]), + + + $this->fixture('Class_Article', + ['id' => 9, + 'titre' =>'La fête de la frite', + 'date_creation' => '2011-01-20', + 'contenu' => 'test', + 'events_debut' => '2011-09-03', + 'events_fin' => '2011-09-03', + 'categorie' => $this->fixture('Class_ArticleCategorie', + ['id' => 12, + 'libelle' => 'Alimentaire'])]) - $articles = [ Class_Article::getLoader() - ->newInstanceWithId(1) - ->setTitre('La fête de la banane') - ->setDateCreation('2011-01-15') - ->setContenu('Pas qu\'à moitié {FIN} Une fête qui glisse !') - ->setEventsDebut('2011-09-03') - ->setEventsFin('2011-10-03') - ->setCategorie( - Class_ArticleCategorie::getLoader()->newInstanceWithId(1) - ->setLibelle('Alimentaire') - ->setBib(Class_Bib::getLoader() - ->newInstanceWithId(1) - ->setLibelle('Bonlieu'))), - Class_Article::getLoader() - ->newInstanceWithId(9) - ->setTitre('La fête de la frite') - ->setDateCreation('2011-01-20') - ->setContenu('') - ->setEventsDebut('2011-09-03') - ->setEventsFin('2011-09-03') - ->setCategorie( - Class_ArticleCategorie::getLoader()->newInstanceWithId(1) - ->setLibelle('Alimentaire') - )]; - - $articles = Class_Article::getLoader()->sortArticles($articles, $this->display_order); - - $prefs_module_calendar = ['titre' => "Calendrier des animations", - 'event_date' => '2011-09-03', - 'id_bib' => null, - 'id_categorie' => '', - 'events_only' => true, - 'published' => false, - 'display_next_event' => 1, - 'nb_events' => 3, - 'display_mode' => $this->display_mode, - 'display_order' => $this->display_order, - 'display_cat_select' => false, - 'display_event_info'=>false, - 'rss_avis' => false, - 'boite' => null ]; - if ($this->display_mode == "Summary") - $prefs_module_calendar['summary_content']="Summary"; + $articles = Class_Article::getLoader()->sortArticles($articles, $this->display_order); + + $prefs_module_calendar = ['titre' => "Calendrier des animations", + 'event_date' => '2011-09-03', + 'id_bib' => null, + 'id_categorie' => '', + 'events_only' => true, + 'published' => false, + 'display_next_event' => 1, + 'nb_events' => 3, + 'display_mode' => $this->display_mode, + 'display_order' => $this->display_order, + 'display_cat_select' => false, + 'display_event_info'=>false, + 'rss_avis' => false, + 'boite' => null + ]; - $this->_article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') - ->whenCalled('getArticlesByPreferences') - ->with($prefs_module_calendar) - ->answers($articles) + if ($this->display_mode == "Summary") + $prefs_module_calendar['summary_content']="Summary"; - ->whenCalled('getArticlesByPreferences') - ->with([ - 'event_date' => '2011-09-03', - 'events_only' => true, - 'published' => false, - 'id_bib' => null, - 'display_mode' => $this->display_mode, - 'display_order' => $this->display_order - ]) - ->answers($articles) + $this->_article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') + ->whenCalled('getArticlesByPreferences') + ->with($prefs_module_calendar) + ->answers($articles) - ->whenCalled('getArticlesByPreferences') - ->answers($articles); + ->whenCalled('getArticlesByPreferences') + ->with([ + 'event_date' => '2011-09-03', + 'events_only' => true, + 'published' => false, + 'id_bib' => null, + 'display_mode' => $this->display_mode, + 'display_order' => $this->display_order + ]) + ->answers($articles) + ->whenCalled('getArticlesByPreferences') + ->answers($articles); - $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&id_profil=2&select_id_categorie=all', true); } } @@ -385,6 +396,53 @@ class CmsControllerArticleViewByDateOnMonthTest extends AbstractControllerTestCa +class CmsControllerArticleViewByDatePickDaTyest extends AbstractCmsControllerArticleViewByDateTest { + public function setUp() { + parent::setUp(); + $this->display_mode='Title'; + } + + /** @test */ + public function feteDeLaFriteShouldBePresentOnSaturday() { + parent::fixturesForDispatch(); + Class_Article::find(9)->setPickDay('6')->save(); + $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&id_profil=2&select_id_categorie=all', true); + + $this->assertXpathContentContains('//ul//li//a', 'La fête de la frite'); + } + + + /** @test */ + public function feteDeLaFriteShouldBePresentOnSunday() { + parent::fixturesForDispatch(); + Class_Article::find(9)->setPickDay('0')->save(); + $this->dispatch('/cms/articleviewbydate?d=2011-09-04&id_module=8&id_profil=2&select_id_categorie=all', true); + + $this->assertXpathContentContains('//ul//li//a', 'La fête de la frite'); + } + + + /** @test */ + public function feteDeLaFriteShouldBePresentOnMondayAndSunday() { + parent::fixturesForDispatch(); + Class_Article::find(9)->setPickDay('0,6')->save(); + $this->dispatch('/cms/articleviewbydate?d=2011-09-04&id_module=8&id_profil=2&select_id_categorie=all', true); + + $this->assertXpathContentContains('//ul//li//a', 'La fête de la frite'); + } + + + /** @test */ + public function feteDeLaFriteShouldNotBePresentOnThuesday() { + parent::fixturesForDispatch(); + Class_Article::find(9)->setPickDay('0,1,3,4,5,6')->save(); + $this->dispatch('/cms/articleviewbydate?d=2011-09-06&id_module=8&id_profil=2&select_id_categorie=all', true); + + $this->assertNotXpathContentContains('//ul//li//a', 'La fête de la frite'); + } + +} + class CmsControllerArticleViewByDateTest extends AbstractCmsControllerArticleViewByDateTest { public function setUp() { parent::setUp(); diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index cd82c25a734e3f9a085dddd42c3d6523ba70e8ae..9b5bddb5cf180ad41b971e40645ddb5895ad2085 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -1805,7 +1805,7 @@ abstract class ProfilOptionsControllerProfilBoiteCalendarTestCase extends Abstra 'description' => 'à Moulins', 'events_debut' => '2011-09-05', 'events_fin' => '2011-10-05', - 'pick_day' => '123', + 'pick_day' => '1,2,3', 'categorie' => $fiesta_annecy]); $fete_valleiry = $this->fixture('Class_Article',