diff --git a/VERSIONS_HOTLINE/50953 b/VERSIONS_HOTLINE/50953 new file mode 100644 index 0000000000000000000000000000000000000000..02400a697c515ea3e3ade19b20991158a7c9611a --- /dev/null +++ b/VERSIONS_HOTLINE/50953 @@ -0,0 +1 @@ + - ticket #50953 : Le 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..17c173ce8b081036b2a5eed230acb936af28387a 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..f15021f7e5becf10a410dfc5141a67bc4a70751d 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -44,30 +44,30 @@ class CmsControllerRssNoProfileTest extends AbstractControllerTestCase { class CmsControllerdCalendarRssWithProfileAndArticleTest -extends AbstractControllerTestCase { + extends AbstractControllerTestCase { /** * @param Class_Profil $profil */ protected function _initProfilHook($profil) { $profil->setCfgAccueil( - array( - 'modules' => array( - '1' => array( - 'division' => '1', - 'type_module' => 'NEWS', - 'preferences' => array( - 'titre' => 'Les dernières nouvelles', - 'rss_avis' => true, - 'type_aff' => 2, - 'display_order' => 'Random', - 'nb_aff' => 2, - 'nb_analyse' => 5 - ) - ) - ), - 'options' => array() - ) - ); + array( + 'modules' => array( + '1' => array( + 'division' => '1', + 'type_module' => 'NEWS', + 'preferences' => array( + 'titre' => 'Les dernières nouvelles', + 'rss_avis' => true, + 'type_aff' => 2, + 'display_order' => 'Random', + 'nb_aff' => 2, + 'nb_analyse' => 5 + ) + ) + ), + 'options' => array() + ) + ); } public function setUp() { @@ -76,19 +76,19 @@ extends AbstractControllerTestCase { CmsController::setTimeSource(new TimeSourceForTest('2014-12-01 14:00:00')); Class_Calendar::setTimeSource(new TimeSourceForTest('2014-12-01 14:00:00')); $fete =$this->fixture('Class_Article', - ['id' => 1, - 'titre' => 'La fête de la banane', - 'contenu' => 'Une fête qui glisse !<img src="'.BASE_URL.'/image/banane.jpg"/>']) + ['id' => 1, + 'titre' => 'La fête de la banane', + 'contenu' => 'Une fête qui glisse !<img src="'.BASE_URL.'/image/banane.jpg"/>']) ->setDateMaj('2011-11-11 11:11:11') ->setEventsDebut('2009-09-09 09:09:09'); $fete_frite=$this->fixture('Class_Article', - ['id' => 2, - 'titre' => 'La fête de la frite', - 'contenu' => 'Une fête qui sent !', - 'debut' => '2012-12-12 12:12:12', - 'events_debut' => '2012-12-13', - 'all_day' => true]); + ['id' => 2, + 'titre' => 'La fête de la frite', + 'contenu' => 'Une fête qui sent !', + 'debut' => '2012-12-12 12:12:12', + 'events_debut' => '2012-12-13', + 'all_day' => true]); Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') ->whenCalled('getArticlesByPreferences') @@ -182,24 +182,24 @@ class CmsControllerRssWithProfileAndArticle extends AbstractControllerTestCase { */ protected function _initProfilHook($profil) { $profil->setCfgAccueil( - array( - 'modules' => array( - '1' => array( - 'division' => '1', - 'type_module' => 'NEWS', - 'preferences' => array( - 'titre' => 'Les dernières nouvelles', - 'rss_avis' => true, - 'type_aff' => 2, - 'display_order' => 'Random', - 'nb_aff' => 2, - 'nb_analyse' => 5 - ) - ) - ), - 'options' => array() - ) - ); + array( + 'modules' => array( + '1' => array( + 'division' => '1', + 'type_module' => 'NEWS', + 'preferences' => array( + 'titre' => 'Les dernières nouvelles', + 'rss_avis' => true, + 'type_aff' => 2, + 'display_order' => 'Random', + 'nb_aff' => 2, + 'nb_analyse' => 5 + ) + ) + ), + 'options' => array() + ) + ); } @@ -209,15 +209,15 @@ class CmsControllerRssWithProfileAndArticle extends AbstractControllerTestCase { Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') ->whenCalled('getArticlesByPreferences') ->answers(array( - Class_Article::getLoader() - ->newInstanceWithId(1) - ->setTitre('La fête de la banane') - ->setContenu('Une fête qui glisse !'), - Class_Article::getLoader() - ->newInstanceWithId(2) - ->setTitre('La fête de la frite') - ->setContenu('Une fête qui sent !'), - )); + Class_Article::getLoader() + ->newInstanceWithId(1) + ->setTitre('La fête de la banane') + ->setContenu('Une fête qui glisse !'), + Class_Article::getLoader() + ->newInstanceWithId(2) + ->setTitre('La fête de la frite') + ->setContenu('Une fête qui sent !'), + )); $this->dispatch('cms/rss?id_profil=2&id_module=1'); @@ -265,47 +265,63 @@ class CmsControllerRssWithProfileAndArticle extends AbstractControllerTestCase { abstract class AbstractCmsControllerArticleViewByDateTest extends AbstractControllerTestCase { + protected $_article_loader; protected $display_mode = "Title"; protected $display_order = "EventDebut"; + public function dispatchViewByDate() { + $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' =>[]]] - ); + ['modules' => + ['8' => ['division' => '0', + 'type_module' => 'CALENDAR', + 'preferences' => ['display_mode' => $this->display_mode, + 'display_order' => $this->display_order]], + 'options' =>[]]] + ); Class_AdminVar::newInstanceWithId('WORKFLOW', ['valeur' => '']); - - $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') - )]; + $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()->sortArticles($articles, $this->display_order); @@ -323,7 +339,7 @@ abstract class AbstractCmsControllerArticleViewByDateTest extends AbstractContro 'display_event_info'=>false, 'rss_avis' => false, 'boite' => null - ]; + ]; if ($this->display_mode == "Summary") $prefs_module_calendar['summary_content']="Summary"; @@ -335,20 +351,18 @@ abstract class AbstractCmsControllerArticleViewByDateTest extends AbstractContro ->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 - ]) + '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 +399,57 @@ class CmsControllerArticleViewByDateOnMonthTest extends AbstractControllerTestCa +class CmsControllerArticleViewByDatePickDayTest 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(); @@ -392,6 +457,7 @@ class CmsControllerArticleViewByDateTest extends AbstractCmsControllerArticleVie $this->dispatchViewByDate(); } + /** @test */ public function feteDeLaBananeTitleShouldBePresent() { $this->assertXpathContentContains('//ul//li//a', 'La fête de la banane'); @@ -448,14 +514,14 @@ class CmsControllerProfilDivisionTest extends AbstractCmsControllerArticleViewBy 'select_annexe' => 'on']], '10' => ['division' => '3', - 'type_module' => 'NEWS', - 'preferences' => ['titre' => 'Articles']], + 'type_module' => 'NEWS', + 'preferences' => ['titre' => 'Articles']], '11' => ['division' => '1', - 'type_module' => 'LOGIN', - 'preferences' => ['lien_connexion' => 'Par ici la connexion']], + 'type_module' => 'LOGIN', + 'preferences' => ['lien_connexion' => 'Par ici la connexion']], - ]]; + ]]; Class_Profil::getCurrentProfil()->setCfgAccueil($cfg_accueil_jeunesse); $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&id_profil=2&select_id_categorie=all', true); } @@ -543,13 +609,13 @@ class CmsControllerArticleViewByDateWithOnlyArticlePortailTest extends AbstractC $this->_article_loader = Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') ->whenCalled('getArticlesByPreferences') ->answers([Class_Article::newInstanceWithId(1, - ['titre' => 'La fête de la frite', - 'content' => '', - 'events_debut' => '2011-09-03', - 'events_fin' => '2011-09-03', - 'categorie' => Class_ArticleCategorie::newInstanceWithId(1, - ['libelle' => 'Alimentaire'])]) - ]); + ['titre' => 'La fête de la frite', + 'content' => '', + 'events_debut' => '2011-09-03', + 'events_fin' => '2011-09-03', + 'categorie' => Class_ArticleCategorie::newInstanceWithId(1, + ['libelle' => 'Alimentaire'])]) + ]); $this->dispatch('/cms/articleviewbydate?d=2011-09-03&id_module=8&id_profil=2&select_id_categorie=all', true); } @@ -750,7 +816,7 @@ abstract class CmsControllerWithFeteDeLaFriteTestCase extends AbstractController ->setValeur(0); $bonlieu = $this->fixture('Class_Bib', ['id' => 1, - 'libelle' => 'Bonlieu']); + 'libelle' => 'Bonlieu']); $annecy = $this->fixture('Class_Lieu', ['id' => '4156465', @@ -763,15 +829,15 @@ abstract class CmsControllerWithFeteDeLaFriteTestCase extends AbstractController 'bib' => $bonlieu ]); $avis_mimi = $this->fixture('Class_Avis' , ['id' => 34, - 'auteur' => $this->fixture('Class_Users' , ['id'=> 98, - 'pseudo' => 'Mimi', - 'password' => 'toto', - 'login' => 'mimi']), - 'date_avis' => '2012-02-05', - 'note'=>4, - 'entete' => "Hmmm", - 'avis'=> 'ça a l\'air bon' - ]); + 'auteur' => $this->fixture('Class_Users' , ['id'=> 98, + 'pseudo' => 'Mimi', + 'password' => 'toto', + 'login' => 'mimi']), + 'date_avis' => '2012-02-05', + 'note'=>4, + 'entete' => "Hmmm", + 'avis'=> 'ça a l\'air bon' + ]); $avis_mimi->beWrittenByAbonne(); @@ -1323,14 +1389,14 @@ abstract class CmsControllerListTestCase extends AbstractControllerTestCase { */ protected function _createFeteDeLaFriteAndMatsumotoArticles() { return array( - Class_Article::newInstanceWithId(224) - ->setTitre('La fête de la frite') - ->setDescription('Ce soir ça frite !') - ->setContenu('<div>Une fête appétissante</div>'), - Class_Article::newInstanceWithId(225) - ->setTitre('Dédicaces de Leiji Matsumoto sama') - ->setContenu('<div>Albaaaaaator, albaaaator</div>') - ); + Class_Article::newInstanceWithId(224) + ->setTitre('La fête de la frite') + ->setDescription('Ce soir ça frite !') + ->setContenu('<div>Une fête appétissante</div>'), + Class_Article::newInstanceWithId(225) + ->setTitre('Dédicaces de Leiji Matsumoto sama') + ->setContenu('<div>Albaaaaaator, albaaaator</div>') + ); } /** @@ -1365,8 +1431,8 @@ abstract class CmsControllerListTestCase extends AbstractControllerTestCase { /** @test */ public function workflowAndTranslationFilterShouldBeCalled() { $this->assertTrue( - Class_Article::getLoader()->methodHasBeenCalled('filterByLocaleAndWorkflow') - ); + Class_Article::getLoader()->methodHasBeenCalled('filterByLocaleAndWorkflow') + ); } } @@ -1438,15 +1504,15 @@ class CmsControllerArticleViewSelectionFromHorizontalMenuBoxTest extends Abstrac 'picto' => 'bookmark.png', 'preferences' => [], 'sous_menus' => [ - ['type_menu' => 'NEWS', - 'libelle' => 'Nouvelles', - 'picto' => 'vide.gif', - 'preferences' => ['titre' => 'Nouvelles', - 'id_items' => 2, - 'display_order' => 'Selection']] - ] - ]] - ]]; + ['type_menu' => 'NEWS', + 'libelle' => 'Nouvelles', + 'picto' => 'vide.gif', + 'preferences' => ['titre' => 'Nouvelles', + 'id_items' => 2, + 'display_order' => 'Selection']] + ] + ]] + ]]; $this->fixture('Class_Profil', ['id' => 3, 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',