Beispiel #1
0
 function testRenderInputNameAndId()
 {
     $r = Request::create('/');
     $f = new \SQRT\Form($r);
     $el = new Input('age', 'Возраст', $f);
     $this->assertEquals('age', $el->getInputName(), 'Name для поля для формы без имени');
     $this->assertEquals('form-age', $el->getInputId(), 'ID для поля для формы без имени');
     $this->assertEquals('<input class="one" id="form-age" name="age" type="text" />', $el->render('one')->toHTML(), 'Генерация INPUT');
     $f->setName('profile');
     $this->assertEquals('profile[age]', $el->getInputName(), 'Name для поля именованой формы');
     $this->assertEquals('form-profile-age', $el->getInputId(), 'ID для поля именованой формы');
     $this->assertEquals('<input id="form-profile-age" name="profile[age]" type="text" />', $el->render()->toHTML(), 'Генерация INPUT для именованой формы');
     $this->assertEquals('<input id="ololo" name="profile[age]" type="text" />', $el->render(array('id' => 'ololo'))->toHTML(), 'Генерация INPUT с переопределенными параметрами');
 }