public function testParseOptions() { $expected = array(array('value' => 1, 'text' => 'Text1'), array('value' => 2, 'text' => 'Text2')); $actual = InputHelper::parseOptions(array(1 => 'Text1', 2 => 'Text2')); $this->assertEquals($expected, $actual); $expected = array(array('value' => 1, 'text' => 'Text1'), array('value' => 2, 'text' => 'Text2')); $actual = InputHelper::parseOptions($expected); $this->assertEquals($expected, $actual); }
public function validate() { if ($this->required && !$this->checked) { $this->errorMessage = "Please select an item."; return false; } if ($this->checked && !InputHelper::isValidValue($this->checked, $this->options)) { $this->errorMessage = "Invalid selection."; return false; } return true; }