Docblock update
[htmlpurifier.git] / tests / HTMLPurifier / HTMLModule / FormsTest.php
blob09b0d4d1e71e8db2f9194cb9ec24098e0e02375d
1 <?php
3 class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
6 public function setUp()
8 parent::setUp();
9 $this->config->set('HTML.Trusted', true);
10 $this->config->set('Attr.EnableID', true);
13 public function testBasicUse()
15 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
16 $this->assertResult( // need support for label for later
18 <form action="http://somesite.com/prog/adduser" method="post">
19 <p>
20 <label>First name: </label>
21 <input type="text" id="firstname" /><br />
22 <label>Last name: </label>
23 <input type="text" id="lastname" /><br />
24 <label>email: </label>
25 <input type="text" id="email" /><br />
26 <input type="radio" name="sex" value="Male" /> Male<br />
27 <input type="radio" name="sex" value="Female" /> Female<br />
28 <input type="submit" value="Send" /> <input type="reset" />
29 </p>
30 </form>'
34 public function testSelectOption()
36 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
37 $this->assertResult('
38 <form action="http://somesite.com/prog/component-select" method="post">
39 <p>
40 <select multiple="multiple" size="4" name="component-select">
41 <option selected="selected" value="Component_1_a">Component_1</option>
42 <option selected="selected" value="Component_1_b">Component_2</option>
43 <option>Component_3</option>
44 <option>Component_4</option>
45 <option>Component_5</option>
46 <option>Component_6</option>
47 <option>Component_7</option>
48 </select>
49 <input type="submit" value="Send" /><input type="reset" />
50 </p>
51 </form>
52 ');
55 public function testSelectOptgroup()
57 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
58 $this->assertResult('
59 <form action="http://somesite.com/prog/someprog" method="post">
60 <p>
61 <select name="ComOS">
62 <option selected="selected" label="none" value="none">None</option>
63 <optgroup label="PortMaster 3">
64 <option label="3.7.1" value="pm3_3.7.1">PortMaster 3 with ComOS 3.7.1</option>
65 <option label="3.7" value="pm3_3.7">PortMaster 3 with ComOS 3.7</option>
66 <option label="3.5" value="pm3_3.5">PortMaster 3 with ComOS 3.5</option>
67 </optgroup>
68 <optgroup label="PortMaster 2">
69 <option label="3.7" value="pm2_3.7">PortMaster 2 with ComOS 3.7</option>
70 <option label="3.5" value="pm2_3.5">PortMaster 2 with ComOS 3.5</option>
71 </optgroup>
72 <optgroup label="IRX">
73 <option label="3.7R" value="IRX_3.7R">IRX with ComOS 3.7R</option>
74 <option label="3.5R" value="IRX_3.5R">IRX with ComOS 3.5R</option>
75 </optgroup>
76 </select>
77 </p>
78 </form>
79 ');
82 public function testTextarea()
84 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
85 $this->assertResult('
86 <form action="http://somesite.com/prog/text-read" method="post">
87 <p>
88 <textarea name="thetext" rows="20" cols="80">
89 First line of initial text.
90 Second line of initial text.
91 </textarea>
92 <input type="submit" value="Send" /><input type="reset" />
93 </p>
94 </form>
95 ');
98 // label tests omitted
100 public function testFieldset()
102 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
103 $this->assertResult('
104 <form action="..." method="post">
105 <fieldset>
106 <legend>Personal Information</legend>
107 Last Name: <input name="personal_lastname" type="text" tabindex="1" />
108 First Name: <input name="personal_firstname" type="text" tabindex="2" />
109 Address: <input name="personal_address" type="text" tabindex="3" />
110 ...more personal information...
111 </fieldset>
112 <fieldset>
113 <legend>Medical History</legend>
114 <input name="history_illness" type="checkbox" value="Smallpox" tabindex="20" />Smallpox
115 <input name="history_illness" type="checkbox" value="Mumps" tabindex="21" /> Mumps
116 <input name="history_illness" type="checkbox" value="Dizziness" tabindex="22" /> Dizziness
117 <input name="history_illness" type="checkbox" value="Sneezing" tabindex="23" /> Sneezing
118 ...more medical history...
119 </fieldset>
120 <fieldset>
121 <legend>Current Medication</legend>
122 Are you currently taking any medication?
123 <input name="medication_now" type="radio" value="Yes" tabindex="35" />Yes
124 <input name="medication_now" type="radio" value="No" tabindex="35" />No
126 If you are currently taking medication, please indicate
127 it in the space below:
128 <textarea name="current_medication" rows="20" cols="50" tabindex="40"></textarea>
129 </fieldset>
130 </form>
134 public function testInputTransform()
136 $this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
137 $this->assertResult('<input type="checkbox" />', '<input type="checkbox" value="" />');
140 public function testTextareaTransform()
142 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
143 $this->assertResult('<textarea></textarea>', '<textarea cols="22" rows="3"></textarea>');
146 public function testTextInFieldset()
148 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
149 $this->assertResult('<fieldset> <legend></legend>foo</fieldset>');
152 public function testStrict()
154 $this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
155 $this->assertResult('<form action=""></form>', '');
158 public function testLegacy()
160 $this->assertResult('<form action=""></form>');
161 $this->assertResult('<form action=""><input align="left" /></form>');
166 // vim: et sw=4 sts=4