icingaweb2-module-director/test/php/library/Director/CustomVariable/CustomVariablesTest.php

42 lines
962 B
PHP

<?php
namespace Tests\Icinga\Module\Director\CustomVariable;
use Icinga\Module\Director\CustomVariable\CustomVariables;
use Icinga\Module\Director\Test\BaseTestCase;
class CustomVariablesTest extends BaseTestCase
{
protected $indent = ' ';
public function testWhetherSpecialKeyNames()
{
$vars = $this->newVars();
$vars->bla = 'da';
$vars->{'aBc'} = 'normal';
$vars->{'a-0'} = 'special';
$expected = $this->indentVarsList(array(
'vars["a-0"] = "special"',
'vars.aBc = "normal"',
'vars.bla = "da"'
));
$this->assertEquals(
$vars->toConfigString(),
$expected
);
}
protected function indentVarsList($vars)
{
return $this->indent . implode(
"\n" . $this->indent,
$vars
) . "\n";
}
protected function newVars()
{
return new CustomVariables();
}
}