fixed issues with duplicating empty type and module settings

This commit is contained in:
Roland Gruber 2017-07-02 09:35:27 +02:00
parent 7264498645
commit 499c6b6a2c
2 changed files with 18 additions and 4 deletions

View File

@ -643,24 +643,24 @@ class LAMConfig {
else {
$subKeyword = $parts[1];
$startIndex = $startIndex + strlen($subKeyword) + 2;
$option = substr($line, $startIndex);
if (empty($option)) {
continue;
}
// module settings
if ($keyword == 'modules') {
$option = substr($line, $startIndex);
$this->moduleSettings[$subKeyword] = explode(LAMConfig::LINE_SEPARATOR, $option);
}
// type settings
if ($keyword == 'types') {
$option = substr($line, $startIndex);
$this->typeSettings[$subKeyword] = $option;
}
// tool settings
if ($keyword == 'tools') {
$option = substr($line, $startIndex);
$this->toolSettings[$subKeyword] = $option;
}
// job settings
if ($keyword == 'jobs') {
$option = substr($line, $startIndex);
$this->jobSettings[$subKeyword] = explode(LAMConfig::LINE_SEPARATOR, $option);
}
}

View File

@ -699,6 +699,20 @@ class LAMConfigTest extends PHPUnit_Framework_TestCase {
$this->assertFalse(empty($token));
}
/**
* Checks that number of settings stays constant over multiple saves.
*/
public function testMultiSave() {
$sizeModSettings = sizeof($this->lAMConfig->get_moduleSettings());
$sizeTypeSettings = sizeof($this->lAMConfig->get_typeSettings());
$this->doSave();
$this->assertEquals($sizeModSettings, sizeof($this->lAMConfig->get_moduleSettings()));
$this->assertEquals($sizeTypeSettings, sizeof($this->lAMConfig->get_typeSettings()));
$this->doSave();
$this->assertEquals($sizeModSettings, sizeof($this->lAMConfig->get_moduleSettings()));
$this->assertEquals($sizeTypeSettings, sizeof($this->lAMConfig->get_typeSettings()));
}
/**
* Saves the config
*/