ExtensibleSet: do not quote values, adjust tests

This commit is contained in:
Thomas Gelf 2016-02-29 18:30:32 +01:00
parent dcd2823a73
commit 4b46330855
2 changed files with 19 additions and 9 deletions

View File

@ -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
);
}

View File

@ -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,