From 8f0df229ed3e82191f118594ea5145c9d5942d7b Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 18 Aug 2015 20:12:32 +0200 Subject: Form: added Button element #1312 --- _test/tests/inc/form/buttonelement.test.php | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 _test/tests/inc/form/buttonelement.test.php (limited to '_test/tests') 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 @@ +addButton('foo', 'Hello World')->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 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 World')->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); + } +} -- cgit v1.2.3