summaryrefslogtreecommitdiff
path: root/_test/tests/inc/form/buttonelement.test.php
diff options
context:
space:
mode:
authorGuy Brand <gb@unistra.fr>2015-08-23 15:54:03 +0200
committerGuy Brand <gb@unistra.fr>2015-08-23 15:54:03 +0200
commitd1c5a21205ecdf83c4cbdcd9245556121688e798 (patch)
treef99aacf8e4e2aad00b106d9b905a14c3536ba935 /_test/tests/inc/form/buttonelement.test.php
parent2beabe635c6b98fcf412ba42d137a5de33543109 (diff)
parent0f0d29909c63f9897c9c003e6d3e3b8381a6f36d (diff)
downloadrpg-d1c5a21205ecdf83c4cbdcd9245556121688e798.tar.gz
rpg-d1c5a21205ecdf83c4cbdcd9245556121688e798.tar.bz2
Merge branch 'master' into stable
Diffstat (limited to '_test/tests/inc/form/buttonelement.test.php')
-rw-r--r--_test/tests/inc/form/buttonelement.test.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/_test/tests/inc/form/buttonelement.test.php b/_test/tests/inc/form/buttonelement.test.php
new file mode 100644
index 000000000..8e1a7e1e2
--- /dev/null
+++ b/_test/tests/inc/form/buttonelement.test.php
@@ -0,0 +1,40 @@
+<?php
+
+use dokuwiki\Form;
+
+class form_buttonelement_test extends DokuWikiTest {
+
+ function test_simple() {
+ $form = new Form\Form();
+ $form->addButton('foo', 'Hello <b>World</b>')->val('bam')->attr('type', 'submit');
+
+ $html = $form->toHTML();
+ $pq = phpQuery::newDocumentXHTML($html);
+
+ $input = $pq->find('button[name=foo]');
+ $this->assertTrue($input->length == 1);
+ $this->assertEquals('bam', $input->val());
+ $this->assertEquals('submit', $input->attr('type'));
+ $this->assertEquals('Hello <b>World</b>', $input->text()); // tags were escaped
+
+ $b = $input->find('b'); // no tags found
+ $this->assertTrue($b->length == 0);
+ }
+
+ function test_html() {
+ $form = new Form\Form();
+ $form->addButtonHTML('foo', 'Hello <b>World</b>')->val('bam')->attr('type', 'submit');
+
+ $html = $form->toHTML();
+ $pq = phpQuery::newDocumentXHTML($html);
+
+ $input = $pq->find('button[name=foo]');
+ $this->assertTrue($input->length == 1);
+ $this->assertEquals('bam', $input->val());
+ $this->assertEquals('submit', $input->attr('type'));
+ $this->assertEquals('Hello World', $input->text()); // tags are stripped here
+
+ $b = $input->find('b'); // tags found
+ $this->assertTrue($b->length == 1);
+ }
+}