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