Commit 4e95d461 authored by Henri-Damien LAURENT's avatar Henri-Damien LAURENT

Merge branch…

Merge branch 'hotline#115024_magasin_de_theme_la_recherche_avancee_ne_prend_pas_en_compte_le_profil_defini_dans_la_boite' into 'hotline'

hotline #115024 Templates / advanced search : add profil_redirect setting

See merge request !3608
parents 248b9dc3 e699b3f4
Pipeline #10904 passed with stage
in 52 minutes and 13 seconds
- 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
......@@ -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;
}
/**
......
......@@ -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
......@@ -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
......@@ -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;
}
......
......@@ -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());
}
......
<?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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment