diff --git a/library/Class/Article.php b/library/Class/Article.php index 0fd9cd451bfeabef118155ec02947a659f22ac61..8d4bd17770e171e6a2ac5103f5a928b709ac134d 100644 --- a/library/Class/Article.php +++ b/library/Class/Article.php @@ -1132,7 +1132,7 @@ class Class_Article extends Storm_Model_Abstract { public function getIcoInfo() { - return 'ico/liste.gif'; + return 'ico/liste.gif'; } @@ -1169,6 +1169,35 @@ class Class_Article extends Storm_Model_Abstract { public function getLieuLibelle() { return $this->getLieu() ? $this->getLieu()->getLibelle() : '' ; } + + + public static function hasEventForMonth($month) { + return 0 < count(array_merge(Class_Article::getArticlesByPreferences(['event_date' => + date("d-m-Y", + mktime(0, + 0, + 0, + $month, + 1, + (date('m')>$month) ? date('Y') + 1 : date('Y') )), + 'published' => true, + 'events_only'=>'true', + 'status' => 3]), + Class_Article::getArticlesByPreferences(['event_date' => + date("d-m-Y", + mktime(0, + 0, + 0, + $month + 1, + 0, + (date('m')>$month) + ? date('Y') +1 + : date('Y') )), + 'published' => true, + 'events_only'=>'true', + 'status' => 3]))); + } + } ?> \ No newline at end of file diff --git a/tests/library/Class/ArticleTest.php b/tests/library/Class/ArticleTest.php index c9f4af9a7c9763fdcb3d08b01d83b1ec4b897b1d..5cd8a6483a6e3bb80c80e0a1b5e7d78affbbe4f2 100644 --- a/tests/library/Class/ArticleTest.php +++ b/tests/library/Class/ArticleTest.php @@ -951,4 +951,21 @@ class ArticleTestFixtures { )); } +} + + +Class EventsByMonthTest extends Storm_Test_ModelTestCase { + public function setup() { + parent::setup(); + + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Article') + ->whenCalled('findAll') + ->answers([]); + + } + + /** @test **/ + public function fevrierShouldNotContainsEvents() { + $this->assertFalse(Class_Article::hasEventForMonth(2)); + } } \ No newline at end of file