PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / tests / HTMLPurifier / AttrDef / IntegerTest.php
blob2061a3660e2733c4fbccc021c9a5c7a78f768f5c
1 <?php
3 class HTMLPurifier_AttrDef_IntegerTest extends HTMLPurifier_AttrDefHarness
6 public 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 public function assertRange($negative, $zero, $positive)
28 $this->assertDef('-100', $negative);
29 $this->assertDef('-1', $negative);
30 $this->assertDef('0', $zero);
31 $this->assertDef('1', $positive);
32 $this->assertDef('42', $positive);
35 public function testRange()
37 $this->def = new HTMLPurifier_AttrDef_Integer(false);
38 $this->assertRange(false, true, true); // non-negative
40 $this->def = new HTMLPurifier_AttrDef_Integer(false, false);
41 $this->assertRange(false, false, true); // positive
44 // fringe cases
46 $this->def = new HTMLPurifier_AttrDef_Integer(false, false, false);
47 $this->assertRange(false, false, false); // allow none
49 $this->def = new HTMLPurifier_AttrDef_Integer(true, false, false);
50 $this->assertRange(true, false, false); // negative
52 $this->def = new HTMLPurifier_AttrDef_Integer(false, true, false);
53 $this->assertRange(false, true, false); // zero
55 $this->def = new HTMLPurifier_AttrDef_Integer(true, true, false);
56 $this->assertRange(true, true, false); // non-positive
62 // vim: et sw=4 sts=4