2008-08-15 22:57:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_AttrTransform_InputTest extends HTMLPurifier_AttrTransformHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->obj = new HTMLPurifier_AttrTransform_Input();
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testEmptyInput() {
|
|
|
|
$this->assertResult(array());
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testInvalidCheckedWithEmpty() {
|
|
|
|
$this->assertResult(array('checked' => 'checked'), array());
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testInvalidCheckedWithPassword() {
|
|
|
|
$this->assertResult(array(
|
2008-12-06 07:28:20 +00:00
|
|
|
'checked' => 'checked',
|
2008-08-15 22:57:44 +00:00
|
|
|
'type' => 'password'
|
|
|
|
), array(
|
|
|
|
'type' => 'password'
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testValidCheckedWithUcCheckbox() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'checked' => 'checked',
|
|
|
|
'type' => 'CHECKBOX',
|
|
|
|
'value' => 'bar',
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testInvalidMaxlength() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'maxlength' => '10',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'value' => 'foo',
|
|
|
|
), array(
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'value' => 'foo',
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testValidMaxLength() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'maxlength' => '10',
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
// these two are really bad test-cases
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testSizeWithCheckbox() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'value' => 'foo',
|
|
|
|
'size' => '100px',
|
|
|
|
), array(
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'value' => 'foo',
|
|
|
|
'size' => '100',
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testSizeWithText() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'type' => 'password',
|
|
|
|
'size' => '100px', // spurious value, to indicate no validation takes place
|
|
|
|
), array(
|
|
|
|
'type' => 'password',
|
|
|
|
'size' => '100px',
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testInvalidSrc() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'src' => 'img.png',
|
|
|
|
), array());
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
function testMissingValue() {
|
|
|
|
$this->assertResult(array(
|
|
|
|
'type' => 'checkbox',
|
|
|
|
), array(
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'value' => '',
|
|
|
|
));
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-08-15 22:57:44 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|