Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Extracted OptionsResolver component out of Form #3968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 15, 2012
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[OptionsResolver] Fixed Options::replace() method
  • Loading branch information
webmozart committed May 14, 2012
commit 2b46975e322b55e255f5cc7bb1148c8d90a53458
3 changes: 2 additions & 1 deletion src/Symfony/Component/OptionsResolver/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ public function replace(array $options)
}

$this->options = array();

foreach ($options as $option => $value) {
$this->options[$option] = $value;
$this->set($option, $value);
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/Symfony/Component/OptionsResolver/Tests/OptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,21 @@ public function testFailForCyclicDependencies()

$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());
}
}