Fix CSS URL innerHTML/cssText escaping bug.
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / IntegerTest.php
bloba941e31abd76cfe266370485cc61394058a54569
1 <?php
3 class HTMLPurifier_AttrDef_IntegerTest extends HTMLPurifier_AttrDefHarness
6 function test() {
8 $this->def = new HTMLPurifier_AttrDef_Integer();
10 $this->assertDef('0');
11 $this->assertDef('1');
12 $this->assertDef('-1');
13 $this->assertDef('-10');
14 $this->assertDef('14');
15 $this->assertDef('+24', '24');
16 $this->assertDef(' 14 ', '14');
17 $this->assertDef('-0', '0');
19 $this->assertDef('-1.4', false);
20 $this->assertDef('3.4', false);
21 $this->assertDef('asdf', false); // must not return zero
22 $this->assertDef('2in', false); // must not return zero
26 function assertRange($negative, $zero, $positive) {
27 $this->assertDef('-100', $negative);
28 $this->assertDef('-1', $negative);
29 $this->assertDef('0', $zero);
30 $this->assertDef('1', $positive);
31 $this->assertDef('42', $positive);
34 function testRange() {
36 $this->def = new HTMLPurifier_AttrDef_Integer(false);
37 $this->assertRange(false, true, true); // non-negative
39 $this->def = new HTMLPurifier_AttrDef_Integer(false, false);
40 $this->assertRange(false, false, true); // positive
43 // fringe cases
45 $this->def = new HTMLPurifier_AttrDef_Integer(false, false, false);
46 $this->assertRange(false, false, false); // allow none
48 $this->def = new HTMLPurifier_AttrDef_Integer(true, false, false);
49 $this->assertRange(true, false, false); // negative
51 $this->def = new HTMLPurifier_AttrDef_Integer(false, true, false);
52 $this->assertRange(false, true, false); // zero
54 $this->def = new HTMLPurifier_AttrDef_Integer(true, true, false);
55 $this->assertRange(true, true, false); // non-positive
61 // vim: et sw=4 sts=4