Allow unordered OIDs (global and per-os) (#13923)

* Allow unordered OIDs (global and per-os)
Fix global no_bulk setting, was ignored before
(to fix global needed to rework Config::getCombined() a bit to allow a global prefix to be specified)
Removed invalid use of getCombined and updated tests

* fix whitespace

* update os schema
This commit is contained in:
Tony Murray
2022-04-21 21:49:26 -05:00
committed by GitHub
parent 15feac7297
commit d026e9f0cc
11 changed files with 82 additions and 56 deletions
+18 -6
View File
@@ -101,26 +101,38 @@ class ConfigTest extends TestCase
$this->assertNull(Config::getOsSetting('nullos', 'fallback'), 'Incorrectly loaded global setting');
}
public function testGetCombined()
public function testGetCombined(): void
{
$this->setConfig(function (&$config) {
$config['num'] = ['one', 'two'];
$config['withprefix']['num'] = ['four', 'five'];
$config['os']['nullos']['num'] = ['two', 'three'];
$config['assoc'] = ['a' => 'same', 'b' => 'same'];
$config['withprefix']['assoc'] = ['a' => 'prefix_same', 'd' => 'prefix_same'];
$config['os']['nullos']['assoc'] = ['b' => 'different', 'c' => 'still same'];
$config['os']['nullos']['osset'] = true;
$config['gset'] = true;
$config['os']['nullos']['osset'] = 'ossetting';
$config['gset'] = 'fallbackone';
$config['withprefix']['gset'] = 'fallbacktwo';
});
$this->assertTrue(Config::getCombined('nullos', 'non-existent', true), 'Did not return default value on non-existent key');
$this->assertTrue(Config::getCombined('nullos', 'osset', false), 'Did not return OS value when global value is not set');
$this->assertTrue(Config::getCombined('nullos', 'gset', false), 'Did not return global value when OS value is not set');
$this->assertSame(['default'], Config::getCombined('nullos', 'non-existent', '', ['default']), 'Did not return default value on non-existent key');
$this->assertSame(['ossetting'], Config::getCombined('nullos', 'osset', '', ['default']), 'Did not return OS value when global value is not set');
$this->assertSame(['fallbackone'], Config::getCombined('nullos', 'gset', '', ['default']), 'Did not return global value when OS value is not set');
$this->assertSame(['default'], Config::getCombined('nullos', 'non-existent', 'withprefix.', ['default']), 'Did not return default value on non-existent key');
$this->assertSame(['ossetting'], Config::getCombined('nullos', 'osset', 'withprefix.', ['default']), 'Did not return OS value when global value is not set');
$this->assertSame(['fallbacktwo'], Config::getCombined('nullos', 'gset', 'withprefix.', ['default']), 'Did not return global value when OS value is not set');
$combined = Config::getCombined('nullos', 'num');
sort($combined);
$this->assertEquals(['one', 'three', 'two'], $combined);
$combined = Config::getCombined('nullos', 'num', 'withprefix.');
sort($combined);
$this->assertEquals(['five', 'four', 'three', 'two'], $combined);
$this->assertSame(['a' => 'same', 'b' => 'different', 'c' => 'still same'], Config::getCombined('nullos', 'assoc'));
// should associative not ignore same values (d=>prefix_same)? are associative arrays actually used?
$this->assertSame(['a' => 'prefix_same', 'b' => 'different', 'c' => 'still same'], Config::getCombined('nullos', 'assoc', 'withprefix.'));
}
public function testSet()