Fix two minor bugs, updating Phorum and removing unused $dir variable.
[htmlpurifier/darkodev.git] / tests / HTMLPurifier / ConfigSchema / ValidatorAtomTest.php
blob38625136e1c9cd0007e9048f0d837df82ee4d9d7
1 <?php
3 class HTMLPurifier_ConfigSchema_ValidatorAtomTest extends UnitTestCase
6 protected function expectValidationException($msg) {
7 $this->expectException(new HTMLPurifier_ConfigSchema_Exception($msg));
10 protected function makeAtom($value) {
11 $obj = new stdClass();
12 $obj->property = $value;
13 // Note that 'property' and 'context' are magic wildcard values
14 return new HTMLPurifier_ConfigSchema_ValidatorAtom('context', $obj, 'property');
17 function testAssertIsString() {
18 $this->makeAtom('foo')->assertIsString();
21 function testAssertIsStringFail() {
22 $this->expectValidationException("Property in context must be a string");
23 $this->makeAtom(3)->assertIsString();
26 function testAssertNotNull() {
27 $this->makeAtom('foo')->assertNotNull();
30 function testAssertNotNullFail() {
31 $this->expectValidationException("Property in context must not be null");
32 $this->makeAtom(null)->assertNotNull();
35 function testAssertAlnum() {
36 $this->makeAtom('foo2')->assertAlnum();
39 function testAssertAlnumFail() {
40 $this->expectValidationException("Property in context must be alphanumeric");
41 $this->makeAtom('%a')->assertAlnum();
44 function testAssertAlnumFailIsString() {
45 $this->expectValidationException("Property in context must be a string");
46 $this->makeAtom(3)->assertAlnum();
49 function testAssertNotEmpty() {
50 $this->makeAtom('foo')->assertNotEmpty();
53 function testAssertNotEmptyFail() {
54 $this->expectValidationException("Property in context must not be empty");
55 $this->makeAtom('')->assertNotEmpty();
58 function testAssertIsBool() {
59 $this->makeAtom(false)->assertIsBool();
62 function testAssertIsBoolFail() {
63 $this->expectValidationException("Property in context must be a boolean");
64 $this->makeAtom('0')->assertIsBool();
67 function testAssertIsArray() {
68 $this->makeAtom(array())->assertIsArray();
71 function testAssertIsArrayFail() {
72 $this->expectValidationException("Property in context must be an array");
73 $this->makeAtom('asdf')->assertIsArray();
77 function testAssertIsLookup() {
78 $this->makeAtom(array('foo' => true))->assertIsLookup();
81 function testAssertIsLookupFail() {
82 $this->expectValidationException("Property in context must be a lookup array");
83 $this->makeAtom(array('foo' => 4))->assertIsLookup();
86 function testAssertIsLookupFailIsArray() {
87 $this->expectValidationException("Property in context must be an array");
88 $this->makeAtom('asdf')->assertIsLookup();
92 // vim: et sw=4 sts=4