3 class HTMLPurifier_HTMLModule_FormsTest
extends HTMLPurifier_HTMLModuleHarness
6 public function 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">
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" />
34 public function testSelectOption()
36 $this->config
->set('HTML.Doctype', 'HTML 4.01 Strict');
38 <form action="http://somesite.com/prog/component-select" method="post">
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>
49 <input type="submit" value="Send" /><input type="reset" />
55 public function testSelectOptgroup()
57 $this->config
->set('HTML.Doctype', 'HTML 4.01 Strict');
59 <form action="http://somesite.com/prog/someprog" method="post">
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>
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>
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>
82 public function testTextarea()
84 $this->config
->set('HTML.Doctype', 'HTML 4.01 Strict');
86 <form action="http://somesite.com/prog/text-read" method="post">
88 <textarea name="thetext" rows="20" cols="80">
89 First line of initial text.
90 Second line of initial text.
92 <input type="submit" value="Send" /><input type="reset" />
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">
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...
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...
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>
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