[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 use dokuwiki\Form; 4 5 class form_checkableelement_test extends DokuWikiTest { 6 7 function test_defaults() { 8 $form = new Form\Form(); 9 $form->addRadioButton('foo', 'label text first')->val('first')->attr('checked', 'checked'); 10 $form->addRadioButton('foo', 'label text second')->val('second'); 11 12 $html = $form->toHTML(); 13 $pq = phpQuery::newDocumentXHTML($html); 14 15 $input = $pq->find('input[name=foo]'); 16 $this->assertTrue($input->length == 2); 17 18 $label = $pq->find('label'); 19 $this->assertTrue($label->length == 2); 20 21 $inputs = $pq->find('input[name=foo]'); 22 $this->assertEquals('first', pq($inputs->elements[0])->val()); 23 $this->assertEquals('second', pq($inputs->elements[1])->val()); 24 $this->assertEquals('checked', pq($inputs->elements[0])->attr('checked')); 25 $this->assertEquals('', pq($inputs->elements[1])->attr('checked')); 26 $this->assertEquals('radio', pq($inputs->elements[0])->attr('type')); 27 } 28 29 /** 30 * check that posted values overwrite preset default 31 */ 32 function test_prefill() { 33 global $INPUT; 34 $INPUT->post->set('foo', 'second'); 35 36 37 $form = new Form\Form(); 38 $form->addRadioButton('foo', 'label text first')->val('first')->attr('checked', 'checked'); 39 $form->addRadioButton('foo', 'label text second')->val('second'); 40 41 $html = $form->toHTML(); 42 $pq = phpQuery::newDocumentXHTML($html); 43 44 $inputs = $pq->find('input[name=foo]'); 45 $this->assertEquals('first', pq($inputs->elements[0])->val()); 46 $this->assertEquals('second', pq($inputs->elements[1])->val()); 47 $this->assertEquals('', pq($inputs->elements[0])->attr('checked')); 48 $this->assertEquals('checked', pq($inputs->elements[1])->attr('checked')); 49 $this->assertEquals('radio', pq($inputs->elements[0])->attr('type')); 50 } 51 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body