diff --git a/VERSIONS_HOTLINE/115024 b/VERSIONS_HOTLINE/115024 new file mode 100644 index 0000000000000000000000000000000000000000..2a438fc449ae7ba1b0e0be9c0e6a7f6b7c0e727e --- /dev/null +++ b/VERSIONS_HOTLINE/115024 @@ -0,0 +1 @@ + - ticket #115024 : Magasin de thème : recherche avancée : ajout d'un paramètre pour basculer de profil pour afficher le résultat de recherche \ No newline at end of file diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 6882639a34d559fa02c5ffaa1a2e135f6124a1ea..7e20c182154e2ef67fc15b0b88343fc2224b4eb8 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -1196,13 +1196,17 @@ class Class_Profil extends Storm_Model_Abstract { public function getModulePreference($controller, $action, $pref) { $preferences = $this->getCfgModulesPreferences($controller, $action); - return $preferences[$pref]; + return isset($preferences[$pref]) + ? $preferences[$pref] + : null; } + public function setModulePreference($controller,$action,$pref,$value) { $cfg_modules = $this->getCfgModulesAsArray(); $cfg_modules[$controller][$action][$pref]=$value; $this->setCfgModules($cfg_modules)->save(); + return $this; } /** diff --git a/library/ZendAfi/Form/Configuration/Widget/Action/AdvancedSearch.php b/library/ZendAfi/Form/Configuration/Widget/Action/AdvancedSearch.php index 58986c799fa1339e38098de59f3874814ea2e0a8..ddde4f0219a92e11e44a29f51c96b90e4a8d55ac 100644 --- a/library/ZendAfi/Form/Configuration/Widget/Action/AdvancedSearch.php +++ b/library/ZendAfi/Form/Configuration/Widget/Action/AdvancedSearch.php @@ -31,13 +31,20 @@ class ZendAfi_Form_Configuration_Widget_Action_AdvancedSearch extends ZendAfi_Fo 'selectedLabel' => $this->_('Affichés'), 'availableLabel' => $this->_('Disponibles'), 'multiOptions' => Class_SearchForm::getMultiOptions()]); - } + + $this->addElement('comboProfils', + 'profil_redirect', + ['label' => $this->_('Basculer automatiquement sur le profil'), + 'empty_option' => true]); + } public function initDisplayGroups() { - $this->addDisplayGroup(['forms'], - 'custom_forms', - ['Legend' => $this->_('Formulaires personnalisés')]); + $this + ->addDisplayGroup(['forms'], + 'custom_forms', + ['Legend' => $this->_('Formulaires personnalisés')]); parent::initDisplayGroups(); + $this->addToHeadGroup(['profil_redirect']); } } \ No newline at end of file diff --git a/library/ZendAfi/View/Helper/AdvancedSearch.php b/library/ZendAfi/View/Helper/AdvancedSearch.php index f37bb488a64f5813eb79a8aaa1ca0ce39bc4fe62..1272b2964ab2e8bd47bbd31f16c93e24850f9045 100644 --- a/library/ZendAfi/View/Helper/AdvancedSearch.php +++ b/library/ZendAfi/View/Helper/AdvancedSearch.php @@ -137,11 +137,23 @@ class ZendAfi_View_Helper_AdvancedSearch extends ZendAfi_View_Helper_BaseHelper protected function _populateForm($form, $form_id) { $request = Zend_Controller_Front::getInstance()->getRequest(); $form->populate($request->getParams()); - $form->setAction($this->view->url(['controller' => 'recherche', - 'action' => 'simple', - 'titre' => $this->_('Recherche avancée'), - 'form_id' => $form_id], - null, true)); + + $url_params = ['controller' => 'recherche', + 'action' => 'simple', + 'titre' => $this->_('Recherche avancée'), + 'form_id' => $form_id]; + + if ($profil_redirect = Class_Profil::getCurrentProfil() + ->getModulePreference('recherche', + 'avancee', + 'profil_redirect')) { + $url_params['id_profil'] = $profil_redirect; + } + + + $form->setAction($this->view->url($url_params, + null, + true)); return $form; } } \ No newline at end of file diff --git a/tests/application/modules/AbstractControllerTestCase.php b/tests/application/modules/AbstractControllerTestCase.php index fd3c645c740edc52fb0df231a6929d12dd92c4ff..f6b2a3d65f9248f94b9bf314ac65d541c25220a4 100644 --- a/tests/application/modules/AbstractControllerTestCase.php +++ b/tests/application/modules/AbstractControllerTestCase.php @@ -199,6 +199,7 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe protected function _buildTemplateProfil($attributes) { + Class_AdminVar::set('FEATURES_TRACKING_ENABLE', 0); $disk = $this ->mock() ->whenCalled('filesAt') @@ -219,7 +220,6 @@ abstract class AbstractControllerTestCase extends Zend_Test_PHPUnit_ControllerTe $attributes); (new Intonation_Template)->applyOn($profile); - (new Class_Profil_Promoter())->promote($profile); return $profile; } diff --git a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php index 9265258fde27cad5808f52cb3a4a8ca02163780d..e021039678881c634a9feee4cd9d1c7d78234955 100644 --- a/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php +++ b/tests/scenarios/DriveCheckOut/DriveCheckOutBookingTest.php @@ -540,7 +540,7 @@ class DriveCheckOutBookingPlanDownloadExistingTest extends DriveCheckOutBookingT /** @test */ public function urlToPlanInCurrentProfilShouldBePresent() { - $this->assertContains('/drive-checkout/plan/id_profil/1', $this->_response->getBody()); + $this->assertContains('/drive-checkout/plan/id_profil/23', $this->_response->getBody()); } diff --git a/tests/scenarios/Templates/TemplatesAdvancedSearchTest.php b/tests/scenarios/Templates/TemplatesAdvancedSearchTest.php new file mode 100644 index 0000000000000000000000000000000000000000..83b18501011abd813c3113a80403522b849e92d3 --- /dev/null +++ b/tests/scenarios/Templates/TemplatesAdvancedSearchTest.php @@ -0,0 +1,84 @@ +<?php +/** + * Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +abstract class TemplatesAdvancedSearchTestCase extends Admin_AbstractControllerTestCase { + protected $_storm_default_to_volatile = true; + + public function setUp() { + parent::setUp(); + + + $this->_buildTemplateProfil(['id' => 3, + 'libelle' => 'search result']); + + $this + ->_buildTemplateProfil(['id' => 1, + 'libelle' => 'portal']) + ->setModulePreference('recherche', + 'avancee', + 'profil_redirect', + 3) + ->setModulePreference('recherche', + 'avancee', + 'profil_redirect', + 3) + ->beCurrentProfil(); + } +} + + + + +class TemplatesAdvancedSearchEditTest extends TemplatesAdvancedSearchTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/widget/edit-action/id/recherche_avancee/id_profil/1'); + } + + + /** @test */ + public function pageShouldContainsInputIdForms() { + $this->assertXPath('//div[@id="input_forms"]/input[@id="forms"]'); + } + + + /** @test */ + public function pageShouldContainsSelectIdProfilRedirectWithProfilThreeSelected() { + $this->assertXPathContentContains('//select[@id="profil_redirect"]//option[@value=3][@selected]', + 'search result'); + } +} + + + + +class TemplatesAdvancedSearchWithProfilRedirectTest extends TemplatesAdvancedSearchTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/recherche/avancee'); + } + + + /** @test */ + public function formActionShouldContainsIdProfilThree() { + $this->assertXPath('//form[contains(@action, "/form_id/advanced_form/id_profil/3")]',$this->_response->getBody()); + } +} \ No newline at end of file