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

View File

@ -699,6 +699,20 @@ class LAMConfigTest extends PHPUnit_Framework_TestCase {
$this->assertFalse(empty($token)); $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 * Saves the config
*/ */