blob: 7a5e6d2ea944f349c702bc1907008972c99e0d31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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());
}
}
|