public function testCheckboxes() { $node =
$this->
createNode('input', '',
['type' => 'checkbox', 'name' => 'name'
]);
$field =
new ChoiceFormField($node);
$this->
assertFalse($field->
hasValue(), '->hasValue() returns false when the checkbox is not checked'
);
$this->
assertNull($field->
getValue(), '->getValue() returns null if the checkbox is not checked'
);
$this->
assertFalse($field->
isMultiple(), '->hasValue() returns false for checkboxes'
);
try { $field->
addChoice(new \
DOMElement('input'
));
$this->
fail('->addChoice() throws a \LogicException for checkboxes'
);
} catch (\LogicException
$e) { $this->
assertTrue(true, '->initialize() throws a \LogicException for checkboxes'
);
} $node =
$this->
createNode('input', '',
['type' => 'checkbox', 'name' => 'name', 'checked' => 'checked'
]);
$field =
new ChoiceFormField($node);
$this->
assertTrue($field->
hasValue(), '->hasValue() returns true when the checkbox is checked'
);
$this->
assertEquals('on',
$field->
getValue(), '->getValue() returns 1 if the checkbox is checked and has no value attribute'
);