Prepended constants with C_ to avoid reserved words as per https://www.php.net/manual...
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / AttrTransform / InputTest.php
blob0a87d0b92da2dff069ead311690daa1bd6deb698
1 <?php
3 class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHarness
6 public function setUp()
8 parent::setUp();
9 $this->obj = new HTMLPurifier_AttrTransform_Input();
12 public function testEmptyInput()
14 $this->assertResult(array());
17 public function testInvalidCheckedWithEmpty()
19 $this->assertResult(array('checked' => 'checked'), array());
22 public function testInvalidCheckedWithPassword()
24 $this->assertResult(array(
25 'checked' => 'checked',
26 'type' => 'password'
27 ), array(
28 'type' => 'password'
29 ));
32 public function testValidCheckedWithUcCheckbox()
34 $this->assertResult(array(
35 'checked' => 'checked',
36 'type' => 'CHECKBOX',
37 'value' => 'bar',
38 ));
41 public function testInvalidMaxlength()
43 $this->assertResult(array(
44 'maxlength' => '10',
45 'type' => 'checkbox',
46 'value' => 'foo',
47 ), array(
48 'type' => 'checkbox',
49 'value' => 'foo',
50 ));
53 public function testValidMaxLength()
55 $this->assertResult(array(
56 'maxlength' => '10',
57 ));
60 // these two are really bad test-cases
62 public function testSizeWithCheckbox()
64 $this->assertResult(array(
65 'type' => 'checkbox',
66 'value' => 'foo',
67 'size' => '100px',
68 ), array(
69 'type' => 'checkbox',
70 'value' => 'foo',
71 'size' => '100',
72 ));
75 public function testSizeWithText()
77 $this->assertResult(array(
78 'type' => 'password',
79 'size' => '100px', // spurious value, to indicate no validation takes place
80 ), array(
81 'type' => 'password',
82 'size' => '100px',
83 ));
86 public function testInvalidSrc()
88 $this->assertResult(array(
89 'src' => 'img.png',
90 ), array());
93 public function testMissingValue()
95 $this->assertResult(array(
96 'type' => 'checkbox',
97 ), array(
98 'type' => 'checkbox',
99 'value' => '',
105 // vim: et sw=4 sts=4