diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index 969697e94b85463f2f723fc09e8c54b144a35967..a2fc8413cf8c3a1a517a90b02e7755b3e7619eb1 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -298,6 +298,18 @@ class CmsController extends Zend_Controller_Action { } + /** + * @param array $article + */ + protected function _getPubDate($article) { + if ($article->hasEventsDebut()) + return $article->getEventsDebut(); + + if ($article->hasDebut()) + return $article->getDebut(); + + return $article->getDateMaj(); + } /** * @param array $articles @@ -313,9 +325,7 @@ class CmsController extends Zend_Controller_Action { . $this->_request->getServer('HTTP_HOST') . $this->view->url($article->getUrl()), 'description' => html_entity_decode(Class_CmsUrlTransformer::imgUrlRelativeToAbsolute($article->getFullContent())), - 'lastUpdate' => strtotime($article->hasDebut() - ? $article->getDebut() - : $article->getDateMaj()) + 'lastUpdate' => strtotime($this->_getPubDate($article)) ]; } diff --git a/tests/application/modules/opac/controllers/CmsControllerTest.php b/tests/application/modules/opac/controllers/CmsControllerTest.php index a980dba7b644a7684b9532531dd04bbbb0e292ad..226338958b1aa38a0b151e6b7d4856e880a5b2a6 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -80,7 +80,8 @@ extends AbstractControllerTestCase { ['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'); + ->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', @@ -144,9 +145,10 @@ extends AbstractControllerTestCase { /** @test */ - public function firstItemDateShouldBe11_11_2011() { + public function firstItemDateShouldBe09_09_2009() { $this->assertXpathContentContains('//channel/item[1]/pubDate', - '11 Nov 2011'); + '09 Sep 2009', + $this->_response->getBody()); }