diff options
author | Andreas Gohr <andi@splitbrain.org> | 2015-05-08 17:26:11 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2015-05-08 17:26:11 +0200 |
commit | 6d0ceaf93ca31dfb83fd4325ef2eecd9cef733c0 (patch) | |
tree | 468e38161d822e90e7d8f5b27d333273966fd890 /_test/tests/inc/form/inputelement.test.php | |
parent | e7a32b176701c088bab045437819448bb9adad41 (diff) | |
download | rpg-6d0ceaf93ca31dfb83fd4325ef2eecd9cef733c0.tar.gz rpg-6d0ceaf93ca31dfb83fd4325ef2eecd9cef733c0.tar.bz2 |
added a first few tests.
this is far from comprehensible, but should give an idea how the new
library works and how to write tests
Diffstat (limited to '_test/tests/inc/form/inputelement.test.php')
-rw-r--r-- | _test/tests/inc/form/inputelement.test.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/_test/tests/inc/form/inputelement.test.php b/_test/tests/inc/form/inputelement.test.php new file mode 100644 index 000000000..7a5e6d2ea --- /dev/null +++ b/_test/tests/inc/form/inputelement.test.php @@ -0,0 +1,41 @@ +<?php + +use dokuwiki\Form; + +class form_inputelement_test extends DokuWikiTest { + + function test_defaults() { + $form = new Form\Form(); + $form->addTextInput('foo', 'label text')->val('this is text'); + + $html = $form->toHTML(); + $pq = phpQuery::newDocumentXHTML($html); + + $input = $pq->find('input[name=foo]'); + $this->assertTrue($input->length == 1); + $this->assertEquals('this is text', $input->val()); + + $label = $pq->find('label'); + $this->assertTrue($label->length == 1); + $this->assertEquals('label text', $label->find('span')->text()); + } + + /** + * check that posted values overwrite preset default + */ + function test_prefill() { + global $INPUT; + $INPUT->post->set('foo', 'a new text'); + + $form = new Form\Form(); + $form->addTextInput('foo', 'label text')->val('this is text'); + + $html = $form->toHTML(); + $pq = phpQuery::newDocumentXHTML($html); + + $input = $pq->find('input[name=foo]'); + $this->assertTrue($input->length == 1); + $this->assertEquals('a new text', $input->val()); + } + +} |