public function testOptionWithNoValue() { $node = $this->createSelectNodeWithEmptyOption(array('foo' => false, 'bar' => false)); $field = new ChoiceFormField($node); $field->select('foo'); $this->assertEquals('foo', $field->getValue(), '->select() changes the selected option'); }
public function testSelect() { $node = $this->createNode('input', '', array('type' => 'checkbox', 'name' => 'name', 'checked' => 'checked')); $field = new ChoiceFormField($node); $field->select(true); $this->assertEquals(1, $field->getValue(), '->select() changes the value of the field'); $field->select(false); $this->assertEquals(null, $field->getValue(), '->select() changes the value of the field'); $node = $this->createSelectNode(array('foo' => false, 'bar' => false)); $field = new ChoiceFormField($node); $field->select('foo'); $this->assertEquals('foo', $field->getValue(), '->select() changes the selected option'); }
public function testDisableValidation() { $node = $this->createSelectNode(array('foo' => false, 'bar' => false)); $field = new ChoiceFormField($node); $field->disableValidation(); $field->setValue('foobar'); $this->assertEquals('foobar', $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.'); $node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple')); $field = new ChoiceFormField($node); $field->disableValidation(); $field->setValue(array('foobar')); $this->assertEquals(array('foobar'), $field->getValue(), '->disableValidation() allows to set a value which is not in the selected options.'); }
public function testSelectWithEmptyValue() { $node = $this->createSelectNodeWithEmptyOption(array('' => true, 'Female' => false, 'Male' => false)); $field = new ChoiceFormField($node); $this->assertSame('', $field->getValue()); }