options() public method

public options ( $options )
コード例 #1
0
ファイル: SelectTest.php プロジェクト: rmoorman/laraveldocker
 public function testCanSetSelectedOption()
 {
     $select = new Select('color');
     $select->options(array('red' => 'Red', 'blue' => 'Blue'));
     $expected = '<select name="color"><option value="red">Red</option><option value="blue" selected>Blue</option></select>';
     $result = $select->select('blue')->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit');
     $select->options(array('apple' => 'Granny Smith', 'berry' => 'Blueberry'));
     $expected = '<select name="fruit"><option value="apple" selected>Granny Smith</option><option value="berry">Blueberry</option></select>';
     $result = $select->select('apple')->render();
     $this->assertEquals($expected, $result);
 }
コード例 #2
0
ファイル: SelectTest.php プロジェクト: facilinfo/form
 public function testCanSelectNumericKeys()
 {
     $select = new Select('fruit');
     $select->options(array('1' => 'Granny Smith', '2' => 'Blueberry'));
     $expected = '<select name="fruit"><option value="1" selected>Granny Smith</option><option value="2">Blueberry</option></select>';
     $result = $select->select('1')->render();
     $this->assertEquals($expected, $result);
     $select = new Select('fruit');
     $select->options(array('1' => 'Granny Smith', '2' => 'Blueberry'));
     $expected = '<select name="fruit"><option value="1">Granny Smith</option><option value="2" selected>Blueberry</option></select>';
     $result = $select->select('2')->render();
     $this->assertEquals($expected, $result);
 }