From 2435f2e342d350a457b01eb3f1ed363e2790c8a9 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Thu, 21 Jun 2012 13:51:20 +0000 Subject: [PATCH] =?UTF-8?q?Menu:=20prise=20en=20compte=20des=20param=C3=A8?= =?UTF-8?q?tres=20de=20selection=20articles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../opac/controllers/CmsController.php | 10 +++++ library/Class/Systeme/ModulesMenu.php | 9 +---- .../opac/controllers/CmsControllerTest.php | 38 +++++++++++++++++++ .../ProfilOptionsControllerTest.php | 16 +++++++- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/application/modules/opac/controllers/CmsController.php b/application/modules/opac/controllers/CmsController.php index 318408c6e0f..77131905780 100644 --- a/application/modules/opac/controllers/CmsController.php +++ b/application/modules/opac/controllers/CmsController.php @@ -200,6 +200,7 @@ class CmsController extends Zend_Controller_Action { } + /** * @see ZendAfi_View_Helper_Accueil_MenuVertical */ @@ -207,6 +208,7 @@ class CmsController extends Zend_Controller_Action { $this->_viewArticlesByPreferences($this->_getAllParams()); } + /** * @see ZendAfi_View_Helper_Accueil_News */ @@ -221,6 +223,14 @@ class CmsController extends Zend_Controller_Action { } + /** + * @see ZendAfi_View_Helper_Accueil_News + */ + public function articleviewpreferencesAction() { + $this->_viewArticlesByPreferences($this->_request->getParams()); + } + + public function categorieviewAction() { $articles = Class_Article::getLoader()->getArticlesByPreferences(array( 'id_categorie' => (int)$this->_request->getParam('id') diff --git a/library/Class/Systeme/ModulesMenu.php b/library/Class/Systeme/ModulesMenu.php index 83ee0dee9e4..e2cc787e4b6 100644 --- a/library/Class/Systeme/ModulesMenu.php +++ b/library/Class/Systeme/ModulesMenu.php @@ -177,14 +177,7 @@ class Class_Systeme_ModulesMenu extends Class_Systeme_ModulesAbstract { case "LAST_NEWS": $url = BASE_URL . "/cms/articleviewrecent/nb/" . $preferences["nb"]; break; case "NEWS": // Pour l'instant 1 seul article et 1 seule categorie - if ($preferences["id_items"]) { - $items = explode("-", $preferences["id_items"]); - $url = BASE_URL . "/cms/articleview/id/" . $items[0]; - } - if ($preferences["id_categorie"]) { - $items = explode("-", $preferences["id_categorie"]); - $url = BASE_URL . "/cms/categorieview/id/" . $items[0]; - } + $url = BASE_URL . '/cms/articleviewpreferences?' . http_build_query($preferences); break; case "SITO": // Pour l'instant 1 seul site et pas de categorie if ($preferences["id_items"]) { diff --git a/tests/application/modules/opac/controllers/CmsControllerTest.php b/tests/application/modules/opac/controllers/CmsControllerTest.php index e675a94e260..dbf21b184a2 100644 --- a/tests/application/modules/opac/controllers/CmsControllerTest.php +++ b/tests/application/modules/opac/controllers/CmsControllerTest.php @@ -472,18 +472,26 @@ abstract class CmsControllerListTestCase extends AbstractControllerTestCase { } } + + + class CmsControllerArticleViewRecentTest extends CmsControllerListTestCase { protected function _dispatchHook() { $this->dispatch('/cms/articleviewrecent/nb/2'); } } + + + class CmsControllerViewSummaryTest extends CmsControllerListTestCase { protected function _dispatchHook() { $this->dispatch('/cms/viewsummary'); } } + + class CmsControllerArticleViewSelectionTest extends CmsControllerListTestCase { protected function _dispatchHook() { $this->dispatch('/cms/articleviewselection'); @@ -508,6 +516,36 @@ class CmsControllerArticleViewSelectionTest extends CmsControllerListTestCase { } } + + + +class CmsControllerArticleViewPreferencesTest extends CmsControllerListTestCase { + protected function _dispatchHook() { + $this->dispatch('/cms/articleviewpreferences?id_items=1-3&display_order=Selection'); + } + + + public function setUp() { + parent::setUp(); + $this->preferences = Class_Article::getLoader()->getFirstAttributeForLastCallOn('getArticlesByPreferences'); + } + + + /** @test */ + public function itemsShouldBeOneAndThree() { + $this->assertEquals('1-3', $this->preferences['id_items']); + } + + + /** @test */ + public function orderShouldBeDatePublicationDesc() { + $this->assertEquals('Selection', $this->preferences['display_order']); + } +} + + + + class CmsControllerCategorieViewTest extends CmsControllerListTestCase { protected function _dispatchHook() { $this->dispatch('/cms/categorieview'); diff --git a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php index c9f70074edd..c6af40452c6 100644 --- a/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php +++ b/tests/application/modules/opac/controllers/ProfilOptionsControllerTest.php @@ -43,7 +43,12 @@ abstract class ProfilOptionsControllerWithProfilAdulteTestCase extends AbstractC 'libelle' => 'Google', 'picto' => 'vide.gif', 'preferences' => array('url' => 'http://www.google.com', - 'target' => 0)))), + 'target' => 0)), + array('type_menu' => 'NEWS', + 'libelle' => 'Articles', + 'picto' => 'vide.gif', + 'preferences' => array('id_items' => '1-3', + 'display_order' => 'Selection')) )), 'V' => array( "libelle" => "Menu vertical", "picto" => "vide.gif")); @@ -197,7 +202,14 @@ class ProfilOptionsControllerViewProfilAdulteTest extends ProfilOptionsControlle /** @test */ public function menuHorizontalShouldIncludeExternalLinkToGoogle() { - $this->assertXPathContentContains("//div[@id='menu_horizontal']//li//a[@href='http://www.google.com'][@target='_blank']", 'Google', $this->_response->getBody()); + $this->assertXPathContentContains("//div[@id='menu_horizontal']//li//a[@href='http://www.google.com'][@target='_blank']", 'Google'); + } + + + /** @test */ + public function menuHorizontalShouldIncludeLinkToArticleCms() { + $this->assertXPathContentContains("//div[@id='menu_horizontal']//li//a[contains(@href, 'cms/articleviewpreferences?id_items=1-3&display_order=Selection')]", + 'Articles'); } -- GitLab