Beispiel #1
0
 function testAddElement()
 {
     $r = Request::create('/');
     $f = new Form($r);
     $arr = array(1 => 'One', 2 => 'Two');
     $el = $f->addCheckbox('is_active', 'Вкл');
     $this->assertInstanceOf('SQRT\\Form\\Element\\Checkbox', $el, 'Чекбокс');
     $this->assertEquals($el, $f->field('is_active'));
     $el = $f->addRadio('type', 'Тип', $arr);
     $this->assertInstanceOf('SQRT\\Form\\Element\\Radio', $el, 'Радиобатон');
     $this->assertEquals($arr, $el->getOptions(), 'Список опций');
     $el = $f->addSelect('status', 'Статус', $arr);
     $this->assertInstanceOf('SQRT\\Form\\Element\\Select', $el, 'Селектбокс');
     $this->assertEquals($arr, $el->getOptions(), 'Список опций');
     $el = $f->addInput('name', 'Имя');
     $this->assertInstanceOf('SQRT\\Form\\Element\\Input', $el, 'Инпут');
     $el = $f->addPassword('pass', 'Пароль');
     $this->assertInstanceOf('SQRT\\Form\\Element\\Password', $el, 'Пароль');
     $el = $f->addTextarea('text', 'Текст');
     $this->assertInstanceOf('SQRT\\Form\\Element\\Textarea', $el, 'Текстовое поле');
     $fields = $f->getFields();
     $this->assertCount(6, $fields, 'Всего 5 полей');
     $this->assertArrayHasKey('is_active', $fields, 'Ассоциативный массив по именам');
 }