[ Index ] |
PHP Cross Reference of DokuWiki |
[Summary view] [Print] [Text view]
1 <?php 2 3 use dokuwiki\Form; 4 5 /** 6 * makes form internals accessible for testing 7 */ 8 class TestForm extends Form\Form { 9 /** 10 * @return array list of element types 11 */ 12 function getElementTypeList() { 13 $list = array(); 14 foreach($this->elements as $element) $list[] = $element->getType(); 15 return $list; 16 } 17 18 public function balanceFieldsets() { 19 parent::balanceFieldsets(); 20 } 21 22 } 23 24 class form_form_test extends DokuWikiTest { 25 26 /** 27 * checks that an empty form is initialized correctly 28 */ 29 function test_defaults() { 30 global $INPUT; 31 global $ID; 32 $ID = 'some:test'; 33 $INPUT->get->set('id', $ID); 34 $INPUT->get->set('foo', 'bar'); 35 36 $form = new Form\Form(); 37 $html = $form->toHTML(); 38 $pq = phpQuery::newDocumentXHTML($html); 39 40 $this->assertTrue($pq->find('form')->hasClass('doku_form')); 41 $this->assertEquals(wl($ID, array('foo' => 'bar'), false, '&'), $pq->find('form')->attr('action')); 42 $this->assertEquals('post', $pq->find('form')->attr('method')); 43 44 $this->assertTrue($pq->find('input[name=sectok]')->length == 1); 45 } 46 47 48 function test_fieldsetbalance() { 49 $form = new TestForm(); 50 $form->addFieldsetOpen(); 51 $form->addHTML('ignored'); 52 $form->addFieldsetClose(); 53 $form->balanceFieldsets(); 54 55 $this->assertEquals( 56 array( 57 'fieldsetopen', 58 'html', 59 'fieldsetclose' 60 ), 61 $form->getElementTypeList() 62 ); 63 64 $form = new TestForm(); 65 $form->addHTML('ignored'); 66 $form->addFieldsetClose(); 67 $form->balanceFieldsets(); 68 69 $this->assertEquals( 70 array( 71 'fieldsetopen', 72 'html', 73 'fieldsetclose' 74 ), 75 $form->getElementTypeList() 76 ); 77 78 79 $form = new TestForm(); 80 $form->addFieldsetOpen(); 81 $form->addHTML('ignored'); 82 $form->balanceFieldsets(); 83 84 $this->assertEquals( 85 array( 86 'fieldsetopen', 87 'html', 88 'fieldsetclose' 89 ), 90 $form->getElementTypeList() 91 ); 92 93 $form = new TestForm(); 94 $form->addHTML('ignored'); 95 $form->addFieldsetClose(); 96 $form->addHTML('ignored'); 97 $form->addFieldsetOpen(); 98 $form->addHTML('ignored'); 99 $form->balanceFieldsets(); 100 101 $this->assertEquals( 102 array( 103 'fieldsetopen', 104 'html', 105 'fieldsetclose', 106 'html', 107 'fieldsetopen', 108 'html', 109 'fieldsetclose' 110 ), 111 $form->getElementTypeList() 112 ); 113 } 114 115 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body