diff options
author | Andreas Gohr <andi@splitbrain.org> | 2015-05-11 20:31:16 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2015-05-11 20:31:16 +0200 |
commit | 1f5d8b65a983fe0914971ee0bb4e5e58cbf8c8a7 (patch) | |
tree | 4413a5f46730fb951305a9dd214c696f13acf406 /_test | |
parent | 370c645068595c6750cee2b38eb96aeaac3a9dbb (diff) | |
download | rpg-1f5d8b65a983fe0914971ee0bb4e5e58cbf8c8a7.tar.gz rpg-1f5d8b65a983fe0914971ee0bb4e5e58cbf8c8a7.tar.bz2 |
balance fieldsets
Diffstat (limited to '_test')
-rw-r--r-- | _test/tests/inc/form/form.test.php | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/_test/tests/inc/form/form.test.php b/_test/tests/inc/form/form.test.php index cdf3e5a3a..3ae832b2c 100644 --- a/_test/tests/inc/form/form.test.php +++ b/_test/tests/inc/form/form.test.php @@ -2,6 +2,25 @@ use dokuwiki\Form; +/** + * makes form internals accessible for testing + */ +class TestForm extends Form\Form { + /** + * @return array list of element types + */ + function getElementTypeList() { + $list = array(); + foreach($this->elements as $element) $list[] = $element->getType(); + return $list; + } + + public function balanceFieldsets() { + parent::balanceFieldsets(); + } + +} + class form_form_test extends DokuWikiTest { /** @@ -25,4 +44,72 @@ class form_form_test extends DokuWikiTest { $this->assertTrue($pq->find('input[name=sectok]')->length == 1); } + + function test_fieldsetbalance() { + $form = new TestForm(); + $form->addFieldsetOpen(); + $form->addHTML('ignored'); + $form->addFieldsetClose(); + $form->balanceFieldsets(); + + $this->assertEquals( + array( + 'fieldsetopen', + 'html', + 'fieldsetclose' + ), + $form->getElementTypeList() + ); + + $form = new TestForm(); + $form->addHTML('ignored'); + $form->addFieldsetClose(); + $form->balanceFieldsets(); + + $this->assertEquals( + array( + 'fieldsetopen', + 'html', + 'fieldsetclose' + ), + $form->getElementTypeList() + ); + + + $form = new TestForm(); + $form->addFieldsetOpen(); + $form->addHTML('ignored'); + $form->balanceFieldsets(); + + $this->assertEquals( + array( + 'fieldsetopen', + 'html', + 'fieldsetclose' + ), + $form->getElementTypeList() + ); + + $form = new TestForm(); + $form->addHTML('ignored'); + $form->addFieldsetClose(); + $form->addHTML('ignored'); + $form->addFieldsetOpen(); + $form->addHTML('ignored'); + $form->balanceFieldsets(); + + $this->assertEquals( + array( + 'fieldsetopen', + 'html', + 'fieldsetclose', + 'html', + 'fieldsetopen', + 'html', + 'fieldsetclose' + ), + $form->getElementTypeList() + ); + } + } |