Fix newline issues in tests.
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / HTMLModule / FormsTest.php
blobee990cdb37ee29d50a890e2c60dd976c955e4d87
1 <?php
3 class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
6 function setUp() {
7 parent::setUp();
8 $this->config->set('HTML', 'Trusted', true);
9 $this->config->set('Attr', 'EnableID', true);
10 $this->config->set('Cache', 'DefinitionImpl', null);
13 function testBasicUse() {
14 $this->assertResult( // need support for label for later
16 <form action="http://somesite.com/prog/adduser" method="post">
17 <p>
18 <label>First name: </label>
19 <input type="text" id="firstname" /><br />
20 <label>Last name: </label>
21 <input type="text" id="lastname" /><br />
22 <label>email: </label>
23 <input type="text" id="email" /><br />
24 <input type="radio" name="sex" value="Male" /> Male<br />
25 <input type="radio" name="sex" value="Female" /> Female<br />
26 <input type="submit" value="Send" /> <input type="reset" />
27 </p>
28 </form>'
32 function testSelectOption() {
33 $this->assertResult('
34 <form action="http://somesite.com/prog/component-select" method="post">
35 <p>
36 <select multiple="multiple" size="4" name="component-select">
37 <option selected="selected" value="Component_1_a">Component_1</option>
38 <option selected="selected" value="Component_1_b">Component_2</option>
39 <option>Component_3</option>
40 <option>Component_4</option>
41 <option>Component_5</option>
42 <option>Component_6</option>
43 <option>Component_7</option>
44 </select>
45 <input type="submit" value="Send" /><input type="reset" />
46 </p>
47 </form>
48 ');
51 function testSelectOptgroup() {
52 $this->assertResult('
53 <form action="http://somesite.com/prog/someprog" method="post">
54 <p>
55 <select name="ComOS">
56 <option selected="selected" label="none" value="none">None</option>
57 <optgroup label="PortMaster 3">
58 <option label="3.7.1" value="pm3_3.7.1">PortMaster 3 with ComOS 3.7.1</option>
59 <option label="3.7" value="pm3_3.7">PortMaster 3 with ComOS 3.7</option>
60 <option label="3.5" value="pm3_3.5">PortMaster 3 with ComOS 3.5</option>
61 </optgroup>
62 <optgroup label="PortMaster 2">
63 <option label="3.7" value="pm2_3.7">PortMaster 2 with ComOS 3.7</option>
64 <option label="3.5" value="pm2_3.5">PortMaster 2 with ComOS 3.5</option>
65 </optgroup>
66 <optgroup label="IRX">
67 <option label="3.7R" value="IRX_3.7R">IRX with ComOS 3.7R</option>
68 <option label="3.5R" value="IRX_3.5R">IRX with ComOS 3.5R</option>
69 </optgroup>
70 </select>
71 </p>
72 </form>
73 ');
76 function testTextarea() {
77 $this->assertResult('
78 <form action="http://somesite.com/prog/text-read" method="post">
79 <p>
80 <textarea name="thetext" rows="20" cols="80">
81 First line of initial text.
82 Second line of initial text.
83 </textarea>
84 <input type="submit" value="Send" /><input type="reset" />
85 </p>
86 </form>
87 ');
90 // label tests omitted
92 function testFieldset() {
93 $this->assertResult('
94 <form action="..." method="post">
95 <fieldset>
96 <legend>Personal Information</legend>
97 Last Name: <input name="personal_lastname" type="text" tabindex="1" />
98 First Name: <input name="personal_firstname" type="text" tabindex="2" />
99 Address: <input name="personal_address" type="text" tabindex="3" />
100 ...more personal information...
101 </fieldset>
102 <fieldset>
103 <legend>Medical History</legend>
104 <input name="history_illness" type="checkbox" value="Smallpox" tabindex="20" />Smallpox
105 <input name="history_illness" type="checkbox" value="Mumps" tabindex="21" /> Mumps
106 <input name="history_illness" type="checkbox" value="Dizziness" tabindex="22" /> Dizziness
107 <input name="history_illness" type="checkbox" value="Sneezing" tabindex="23" /> Sneezing
108 ...more medical history...
109 </fieldset>
110 <fieldset>
111 <legend>Current Medication</legend>
112 Are you currently taking any medication?
113 <input name="medication_now" type="radio" value="Yes" tabindex="35" />Yes
114 <input name="medication_now" type="radio" value="No" tabindex="35" />No
116 If you are currently taking medication, please indicate
117 it in the space below:
118 <textarea name="current_medication" rows="20" cols="50" tabindex="40"></textarea>
119 </fieldset>
120 </form>
124 function testInputTransform() {
125 $this->assertResult('<input type="checkbox" />', '<input type="checkbox" value="" />');
128 function testTextareaTransform() {
129 $this->assertResult('<textarea></textarea>', '<textarea cols="22" rows="3"></textarea>');
132 function testTextInFieldset() {
133 $this->assertResult('<fieldset> <legend></legend>foo</fieldset>');