[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 use dokuwiki\Form; 4 5 class form_inputelement_test extends DokuWikiTest { 6 7 function test_defaults() { 8 $form = new Form\Form(); 9 $form->addTextInput('foo', 'label text')->val('this is text'); 10 11 $html = $form->toHTML(); 12 $pq = phpQuery::newDocumentXHTML($html); 13 14 $input = $pq->find('input[name=foo]'); 15 $this->assertTrue($input->length == 1); 16 $this->assertEquals('this is text', $input->val()); 17 $this->assertEquals('text', $input->attr('type')); 18 19 $label = $pq->find('label'); 20 $this->assertTrue($label->length == 1); 21 $this->assertEquals('label text', $label->find('span')->text()); 22 } 23 24 /** 25 * check that posted values overwrite preset default 26 */ 27 function test_prefill() { 28 global $INPUT; 29 $INPUT->post->set('foo', 'a new text'); 30 31 $form = new Form\Form(); 32 $form->addTextInput('foo', 'label text')->val('this is text'); 33 34 $html = $form->toHTML(); 35 $pq = phpQuery::newDocumentXHTML($html); 36 37 $input = $pq->find('input[name=foo]'); 38 $this->assertTrue($input->length == 1); 39 $this->assertEquals('a new text', $input->val()); 40 } 41 42 function test_prefill_empty() { 43 global $INPUT; 44 $INPUT->post->set('foo', ''); 45 46 $form = new Form\Form(); 47 $form->addTextInput('foo', 'label text')->val('this is text'); 48 49 $html = $form->toHTML(); 50 $pq = phpQuery::newDocumentXHTML($html); 51 52 $input = $pq->find('input[name=foo]'); 53 $this->assertTrue($input->length == 1); 54 $this->assertEquals('', $input->val()); 55 } 56 57 58 function test_password() { 59 $form = new Form\Form(); 60 $form->addPasswordInput('foo', 'label text')->val('this is text'); 61 62 $html = $form->toHTML(); 63 $pq = phpQuery::newDocumentXHTML($html); 64 65 $input = $pq->find('input[name=foo]'); 66 $this->assertTrue($input->length == 1); 67 $this->assertEquals('this is text', $input->val()); 68 $this->assertEquals('password', $input->attr('type')); 69 70 $label = $pq->find('label'); 71 $this->assertTrue($label->length == 1); 72 $this->assertEquals('label text', $label->find('span')->text()); 73 } 74 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body