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; 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 = ' ') public function renderAs($key, $prefix = ' ')
{ {
$parts = array(); $parts = array();
@ -303,7 +313,7 @@ class ExtensibleSet
if ($this->ownValues !== null) { if ($this->ownValues !== null) {
$parts[] = c::renderKeyValue( $parts[] = c::renderKeyValue(
$key, $key,
c::renderArray($this->ownValues), $this->renderArray($this->ownValues),
$prefix $prefix
); );
} }
@ -312,7 +322,7 @@ class ExtensibleSet
$parts[] = c::renderKeyOperatorValue( $parts[] = c::renderKeyOperatorValue(
$key, $key,
'+=', '+=',
c::renderArray($this->plusValues), $this->renderArray($this->plusValues),
$prefix $prefix
); );
} }
@ -321,7 +331,7 @@ class ExtensibleSet
$parts[] = c::renderKeyOperatorValue( $parts[] = c::renderKeyOperatorValue(
$key, $key,
'-=', '-=',
c::renderArray($this->minusValues), $this->renderArray($this->minusValues),
$prefix $prefix
); );
} }

View File

@ -146,13 +146,13 @@ class ExtensibleSetTest extends BaseTestCase
public function testCombinedDefinitionRendersCorrectly() public function testCombinedDefinitionRendersCorrectly()
{ {
$set = new ExtensibleSet(array('pre', 'def', 'ined')); $set = new ExtensibleSet(array('Pre', 'Def', 'Ined'));
$set->blacklist(array('and', 'not', 'those')); $set->blacklist(array('And', 'Not', 'Those'));
$set->extend('plus this'); $set->extend('PlusThis');
$out = ' key_name = [ "pre", "def", "ined" ]' . "\n" $out = ' key_name = [ Pre, Def, Ined ]' . "\n"
. ' key_name += [ "plus this" ]' . "\n" . ' key_name += [ PlusThis ]' . "\n"
. ' key_name -= [ "and", "not", "those" ]' . "\n"; . ' key_name -= [ And, Not, Those ]' . "\n";
$this->assertEquals( $this->assertEquals(
$out, $out,