public function testReplaceOptionAndNormalizer() { $this->options->set('foo1', 'bar'); $this->options->setNormalizer('foo1', function (Options $options) { return ''; }); $this->options->set('foo2', 'bar'); $this->options->setNormalizer('foo2', function (Options $options) { return ''; }); $this->options->replace(array('foo1' => 'new')); $this->assertEquals(array('foo1' => 'new'), $this->options->all()); }
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()); }
/** * @covers Symfony\Component\OptionsResolver\Options::replace * @expectedException Symfony\Component\OptionsResolver\Exception\OptionDefinitionException */ public function testCannotReplaceAfterOptionWasRead() { $this->options->set('one', 1); $this->options->all(); $this->options->replace(array('two' => '2')); }