diff --git a/library/Director/IcingaConfig/ExtensibleSet.php b/library/Director/IcingaConfig/ExtensibleSet.php index b68f0459..04106d1c 100644 --- a/library/Director/IcingaConfig/ExtensibleSet.php +++ b/library/Director/IcingaConfig/ExtensibleSet.php @@ -296,6 +296,16 @@ class ExtensibleSet return $this; } + protected function renderArray($array) + { + $safe = array(); + foreach ($array as $value) { + $safe[] = c::alreadyRendered($value); + } + + return c::renderArray($safe); + } + public function renderAs($key, $prefix = ' ') { $parts = array(); @@ -303,7 +313,7 @@ class ExtensibleSet if ($this->ownValues !== null) { $parts[] = c::renderKeyValue( $key, - c::renderArray($this->ownValues), + $this->renderArray($this->ownValues), $prefix ); } @@ -312,7 +322,7 @@ class ExtensibleSet $parts[] = c::renderKeyOperatorValue( $key, '+=', - c::renderArray($this->plusValues), + $this->renderArray($this->plusValues), $prefix ); } @@ -321,7 +331,7 @@ class ExtensibleSet $parts[] = c::renderKeyOperatorValue( $key, '-=', - c::renderArray($this->minusValues), + $this->renderArray($this->minusValues), $prefix ); } diff --git a/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php b/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php index 63f343d3..34bd83a3 100644 --- a/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php +++ b/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php @@ -146,13 +146,13 @@ class ExtensibleSetTest extends BaseTestCase public function testCombinedDefinitionRendersCorrectly() { - $set = new ExtensibleSet(array('pre', 'def', 'ined')); - $set->blacklist(array('and', 'not', 'those')); - $set->extend('plus this'); + $set = new ExtensibleSet(array('Pre', 'Def', 'Ined')); + $set->blacklist(array('And', 'Not', 'Those')); + $set->extend('PlusThis'); - $out = ' key_name = [ "pre", "def", "ined" ]' . "\n" - . ' key_name += [ "plus this" ]' . "\n" - . ' key_name -= [ "and", "not", "those" ]' . "\n"; + $out = ' key_name = [ Pre, Def, Ined ]' . "\n" + . ' key_name += [ PlusThis ]' . "\n" + . ' key_name -= [ And, Not, Those ]' . "\n"; $this->assertEquals( $out,