Use Config helper (#10339)

remove usage of global variable
This commit is contained in:
Tony Murray
2019-06-23 00:29:12 -05:00
committed by GitHub
parent 342acf50f1
commit f3ba8947f7
367 changed files with 1589 additions and 1857 deletions

View File

@@ -25,6 +25,7 @@
namespace LibreNMS\Tests;
use LibreNMS\Config;
use LibreNMS\RRD\RrdDefinition;
class RrdDefinitionTest extends TestCase
@@ -40,18 +41,16 @@ class RrdDefinitionTest extends TestCase
*/
public function testWrongType()
{
global $config;
$config['rrd']['step'] = 300;
$config['rrd']['heartbeat'] = 600;
Config::set('rrd.step', 300);
Config::set('rrd.heartbeat', 600);
$def = new RrdDefinition();
$def->addDataset('badtype', 'Something unexpected');
}
public function testNameEscaping()
{
global $config;
$config['rrd']['step'] = 300;
$config['rrd']['heartbeat'] = 600;
Config::set('rrd.step', 300);
Config::set('rrd.heartbeat', 600);
$expected = 'DS:bad_name-is_too_lon:GAUGE:600:0:100 ';
$def = RrdDefinition::make()->addDataset('b a%d$_n:a^me-is_too_lon%g.', 'GAUGE', 0, 100, 600);
@@ -60,11 +59,10 @@ class RrdDefinitionTest extends TestCase
public function testCreation()
{
global $config;
$config['rrd']['step'] = 300;
$config['rrd']['heartbeat'] = 600;
Config::set('rrd.step', 300);
Config::set('rrd.heartbeat', 600);
$expected = 'DS:pos:COUNTER:600:0:125000000000 ' .
'DS:unbound:DERIVE:600:U:U ';
'DS:unbound:DERIVE:600:U:U ';
$def = new RrdDefinition();
$def->addDataset('pos', 'COUNTER', 0, 125000000000);