8000 [OptionsResolver] Fixed Options::replace() method · symfony/symfony@2b46975 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b46975

Browse files
committed
[OptionsResolver] Fixed Options::replace() method
1 parent 16f7d20 commit 2b46975

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Symfony/Component/OptionsResolver/Options.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ public function replace(array $options)
111111
}
112112

113113
$this->options = array();
114+
114115
foreach ($options as $option => $value) {
115-
$this->options[$option] = $value;
116+
$this->set($option, $value);
116117
}
117118
}
118119

src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,21 @@ public function testFailForCyclicDependencies()
198198

199199
$this->options->get('foo');
200200
}
201+
202+
public function testReplaceClearsAndSets()
203+
{
204+
$this->options->set('one', '1');
205+
206+
$this->options->replace(array(
207+
'two' => '2',
208+
'three' => function (Options $options) {
209+
return '2' === $options['two'] ? '3' : 'foo';
210+
}
211+
));
212+
213+
$this->assertEquals(array(
214+
'two' => '2',
215+
'three' => '3',
216+
), $this->options->all());
217+
}
201218
}

0 commit comments

Comments
 (0)
0