Skip to content
Snippets Groups Projects
Commit c3daf9a8 authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'hotline#70772_variable_dilicom_pnb_server_url_ko' into 'stable'

hotline #70772 fix adminvar meta validator

See merge request !2483
parents 527be0c3 3dbbc9ef
Branches
Tags
1 merge request!2483hotline #70772 fix adminvar meta validator
Pipeline #3448 passed with stage
in 26 minutes and 25 seconds
- ticket #70772 : Administration : correction du formulaire de modification des "adminVar".
\ No newline at end of file
......@@ -77,8 +77,16 @@ class Admin_IndexController extends ZendAfi_Controller_Action {
public function adminvareditAction() {
$id = $this->_getParam('cle');
$var = Class_AdminVar::find($id);
if(!$id = $this->_getParam('cle')) {
$this->_helper->notify($this->_('Veuillez renseigner le paramètre "cle".'));
return $this->_redirectClose($this->_getReferer());
}
if(!$var = Class_AdminVar::find($id)) {
$this->_helper->notify($this->_('La clé "%s" n\'existe pas.', $id));
return $this->_redirectClose($this->_getReferer());
}
$form = $var->getForm();
$form->setAction($this->getUrlWithHttpsIfNeeded($id));
$form->setAttrib('data-backurl',
......
......@@ -121,8 +121,14 @@ class Class_AdminVar_Meta {
if (!$validator_class = $this->getAttribute('validate', null))
return;
$validate = new $validator_class($var->getPreviousValue());
if ($validate->isValid($var->getValeur()))
$previous_value = $var->getPreviousValue();
$new_value = $var->getValeur();
if($previous_value == $new_value)
return;
$validate = new $validator_class($previous_value);
if ($validate->isValid($new_value))
return;
array_map([$var, 'addError'], $validate->getMessages());
......
......@@ -51,6 +51,4 @@ class ZendAfi_Validate_Dilicom_IpAdresses extends Zend_Validate_Abstract{
}
return true;
}
}
?>
\ No newline at end of file
}
\ No newline at end of file
......@@ -485,4 +485,26 @@ class IndexControllerBecomeActionTest extends Admin_AbstractControllerTestCase {
public function logedUserShouldBeTest78() {
$this->assertEquals(78, Class_Users::getIdentity()->getId());
}
}
class Admin_IndexControllerAdminvareditTest extends Admin_AbstractControllerTestCase {
protected $_storm_default_to_volatile = true;
public function setUp() {
parent::setUp();
foreach (Class_AdminVar::getKnownVarsKeys() as $name)
Class_AdminVar::set($name, Class_AdminVar::getValueOrDefault($name));
$this->dispatch('/admin/index/adminvaredit/cle/DILICOM_PNB_IP_ADRESSES', true);
}
/** @test */
public function formShouldContainsMultiInput() {
$this->assertXPath('//form//div[@id="multi_inputs_valeur"]');
}
}
\ No newline at end of file
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