PSR-2 reformatting PHPDoc corrections
[htmlpurifier.git] / tests / HTMLPurifier / ConfigSchema / ValidatorAtomTest.php
blob68b4d860609b447e6d9f492180983193a27a6e17
1 <?php
3 class HTMLPurifier_ConfigSchema_ValidatorAtomTest extends UnitTestCase
6 protected function expectValidationException($msg)
8 $this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
11 protected function makeAtom($value)
13 $obj = new stdClass();
14 $obj->property = $value;
15 // Note that 'property' and 'context' are magic wildcard values
16 return new HTMLPurifier_ConfigSchema_ValidatorAtom('context', $obj, 'property');
19 public function testAssertIsString()
21 $this->makeAtom('foo')->assertIsString();
24 public function testAssertIsStringFail()
26 $this->expectValidationException("Property in context must be a string");
27 $this->makeAtom(3)->assertIsString();
30 public function testAssertNotNull()
32 $this->makeAtom('foo')->assertNotNull();
35 public function testAssertNotNullFail()
37 $this->expectValidationException("Property in context must not be null");
38 $this->makeAtom(null)->assertNotNull();
41 public function testAssertAlnum()
43 $this->makeAtom('foo2')->assertAlnum();
46 public function testAssertAlnumFail()
48 $this->expectValidationException("Property in context must be alphanumeric");
49 $this->makeAtom('%a')->assertAlnum();
52 public function testAssertAlnumFailIsString()
54 $this->expectValidationException("Property in context must be a string");
55 $this->makeAtom(3)->assertAlnum();
58 public function testAssertNotEmpty()
60 $this->makeAtom('foo')->assertNotEmpty();
63 public function testAssertNotEmptyFail()
65 $this->expectValidationException("Property in context must not be empty");
66 $this->makeAtom('')->assertNotEmpty();
69 public function testAssertIsBool()
71 $this->makeAtom(false)->assertIsBool();
74 public function testAssertIsBoolFail()
76 $this->expectValidationException("Property in context must be a boolean");
77 $this->makeAtom('0')->assertIsBool();
80 public function testAssertIsArray()
82 $this->makeAtom(array())->assertIsArray();
85 public function testAssertIsArrayFail()
87 $this->expectValidationException("Property in context must be an array");
88 $this->makeAtom('asdf')->assertIsArray();
92 public function testAssertIsLookup()
94 $this->makeAtom(array('foo' => true))->assertIsLookup();
97 public function testAssertIsLookupFail()
99 $this->expectValidationException("Property in context must be a lookup array");
100 $this->makeAtom(array('foo' => 4))->assertIsLookup();
103 public function testAssertIsLookupFailIsArray()
105 $this->expectValidationException("Property in context must be an array");
106 $this->makeAtom('asdf')->assertIsLookup();
110 // vim: et sw=4 sts=4