示例#1
0
 public function testNormalizerWithoutCorrespondingOption()
 {
     $test = $this;
     $this->options->setNormalizer('foo', function (Options $options, $previousValue) use($test) {
         $test->assertNull($previousValue);
         return '';
     });
     $this->assertEquals(array('foo' => ''), $this->options->all());
 }
示例#2
0
    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());
    }
示例#3
0
 /**
  * @covers Symfony\Component\OptionsResolver\Options::clear
  * @expectedException Symfony\Component\OptionsResolver\Exception\OptionDefinitionException
  */
 public function testCannotClearAfterOptionWasRead()
 {
     $this->options->set('one', 1);
     $this->options->all();
     $this->options->clear();
 }