Exemple #1
0
 function testCheckboxListing()
 {
     $arr = array(1 => 'one', 2 => 'two');
     $l = HTML::CheckboxListing($arr, 'myname', 2);
     $this->assertSelectCount('label input[type=checkbox]', 2, $l, '2 чекбокса');
     $this->assertSelectCount('label input[name~=myname]', 2, $l, '2 чексбокса с именем');
     $this->assertSelectCount('label input[checked=checked]', true, $l, '1 чексбокс отмечен');
     $arr = array(0 => '<b>Нет</b>', 1 => 'Да');
     $l = HTML::CheckboxListing($arr, 'test', null);
     $this->assertSelectCount('input[checked=checked]', false, $l, 'Ни один чекбокс не выбран');
     $s = '<input checked="checked" name="test[]" type="checkbox" value="0" />';
     $l = HTML::CheckboxListing($arr, 'test', 0);
     $this->assertGreaterThan(0, strpos($l, $s), 'Выбран чекбокс Нет');
     $l = HTML::CheckboxListing($arr, 'test', array(1, 0));
     $this->assertSelectCount('input[checked=checked]', 2, $l, 'Выбраны оба чекбокса');
     $arr = array('one', 'two');
     echo $l = HTML::CheckboxListing($arr, 'test', 'two', null, true);
     $this->assertSelectCount('input[value=one]', true, $l, 'Чекбокс с значением one');
     $this->assertSelectCount('input[value=two]', true, $l, 'Чекбокс с значением two');
     $this->assertSelectCount('input[checked=checked]', true, $l, 'Отмечен один чекбокс');
 }
Exemple #2
0
 public function render()
 {
     return HTML::CheckboxListing($this->options, $this->getName(), $this->getTaintedValue(), $this->separator, $this->ignore_keys);
 }