[OptionsResolver] Fixed Options::replace() method
This commit is contained in:
parent
16f7d20dff
commit
2b46975e32
@ -111,8 +111,9 @@ class Options implements ArrayAccess, Iterator, Countable
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->options = array();
|
$this->options = array();
|
||||||
|
|
||||||
foreach ($options as $option => $value) {
|
foreach ($options as $option => $value) {
|
||||||
$this->options[$option] = $value;
|
$this->set($option, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,4 +198,21 @@ class OptionsTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$this->options->get('foo');
|
$this->options->get('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testReplaceClearsAndSets()
|
||||||
|
{
|
||||||
|
$this->options->set('one', '1');
|
||||||
|
|
||||||
|
$this->options->replace(array(
|
||||||
|
'two' => '2',
|
||||||
|
'three' => function (Options $options) {
|
||||||
|
return '2' === $options['two'] ? '3' : 'foo';
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->assertEquals(array(
|
||||||
|
'two' => '2',
|
||||||
|
'three' => '3',
|
||||||
|
), $this->options->all());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user