Commit b20ebb23 authored by Patrick Barroca's avatar Patrick Barroca 😁
Browse files

hotline #75868 : fix ref_tags overwriting

parent a3eb3ce7
Pipeline #4336 failed with stage
in 33 minutes and 6 seconds
- ticket #75868 : Administration : Correction de l'enregistrement des profils
\ No newline at end of file
......@@ -999,8 +999,15 @@ class Class_Profil extends Storm_Model_Abstract {
* @return array
*/
public function getCfgSiteAsArray() {
if (!isset($this->_cfg_site_array))
$this->_cfg_site_array = $this->_getCfgAsArrayNamed('Site');
if (isset($this->_cfg_site_array))
return $this->_cfg_site_array;
$params = $this->_getCfgAsArrayNamed('Site');
$valids = static::getCfgSiteKeys();
$this->_cfg_site_array = [];
foreach($params as $k => $v)
if (in_array($k, $valids))
$this->_cfg_site_array[$k] = $v;
return $this->_cfg_site_array;
}
......
......@@ -1574,10 +1574,13 @@ class Admin_ProfilControllerIndexWithLibraryAdminConnectedTest extends Admin_Abs
class ProfilControllerPostDispatchAccueilProfilTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
protected
$_storm_default_to_volatile = true,
$_profil;
public function setUp() {
parent::setUp();
$this->fixture('Class_CustomField',
['id' => 1,
'priority' => 3,
......@@ -1585,6 +1588,7 @@ class ProfilControllerPostDispatchAccueilProfilTest extends Admin_AbstractContro
'field_type' => Class_CustomField_Meta::SELECT,
'options_list' => 'junior; senior; ',
'model' => 'Article']);
$this->fixture('Class_CustomField',
['id' => 2,
'priority' => 3,
......@@ -1618,36 +1622,109 @@ class ProfilControllerPostDispatchAccueilProfilTest extends Admin_AbstractContro
'use_parent_css' => 1,
'page_css' => '',
'division1' => 'CALENDAR-1',
'division2' => 'CALENDAR-0;PRETS-0;NEWSLETTERS-0;MULTIMEDIA-0']);
'division2' => 'CALENDAR-0;PRETS-0;NEWSLETTERS-0;MULTIMEDIA-0',
]);
$this->_profil = Class_Profil::find(1);
}
/** @test */
public function cfgModuleShouldContainsCalendarFiltersDatePlaceAndCustomFilters() {
$prefs = Class_Profil::find(1)->getModuleAccueilPreferences(2, 'CALENDAR');
$prefs = $this->_profil->getModuleAccueilPreferences(2, 'CALENDAR');
$this->assertContains('Boite calendrier', $prefs);
}
/** @test */
public function calendarDivisionShouldBeTwo() {
$config = Class_Profil::find(1)->getModuleAccueilConfig(5, 'CALENDAR');
$this->assertEquals(2,
$config['division']);
$config = $this->_profil->getModuleAccueilConfig(5, 'CALENDAR');
$this->assertEquals(2, $config['division']);
}
/** @test */
public function reservationsDivisionShouldBeOne() {
$config = Class_Profil::find(1)->getModuleAccueilConfig(1, 'RESERVATIONS');
$this->assertEquals(1,
$config['division']);
$config = $this->_profil->getModuleAccueilConfig(1, 'RESERVATIONS');
$this->assertEquals(1, $config['division']);
}
/** @test */
public function profilShouldHaveFiveModules() {
$this->assertEquals(5, count(Class_Profil::find(1)->getCfgAccueilAsArray()['modules']));
$this->assertEquals(5, count($this->_profil->getCfgAccueilAsArray()['modules']));
}
}
class ProfilControllerPostDispatchReferencementProfilTest extends Admin_AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_profil;
public function setUp() {
parent::setUp();
$this->fixture('Class_Profil',
['id' => 1,
'libelle' => 'Afibre'])
->beCurrentProfil();
$this->postDispatch('admin/profil/edit/id_profil/1',
['commentaire' => 'Afibre master profile',
'ref_tags' => 'master,profile,web'
]);
$this->_profil = Class_Profil::find(1);
}
/** @test */
public function commentaireShouldContainsAfibre() {
$this->assertContains('Afibre', $this->_profil->getCommentaire());
}
/** @test */
public function refTagsShouldContainsMaster() {
$this->assertContains('master', $this->_profil->getRefTags());
}
}
/** @see http://forge.afi-sa.fr/issues/75868 */
class ProfilControllerDispatchReferencementProfilTest extends Admin_AbstractControllerTestCase {
protected
$_storm_default_to_volatile = true,
$_profil;
public function setUp() {
parent::setUp();
$profil = $this->fixture('Class_Profil',
['id' => 1,
'libelle' => 'Afibre',
'commentaire' => 'Afibre master power',
'ref_tags' => 'master,power']);
$profil->setCfgSiteParam('ref_tags', '');
$this->dispatch('admin/profil/edit/id_profil/1', true);
$this->_profil = Class_Profil::find(1);
}
/** @test */
public function commentaireShouldContainsAfibre() {
$this->assertXPathContentContains('//textarea[@name="commentaire"]', 'Afibre');
}
/** @test */
public function refTagsShouldContainsMaster() {
$this->assertXPathContentContains('//textarea[@name="ref_tags"]', 'master');
}
}
\ 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