bugfix: trustedproxy is not a delimited pcre
[dokuwiki.git] / _test / tests / inc / common_blank.test.php
blob9df35936a2905dc21f29ebe6c2426eb3f1c00eee
1 <?php
3 class common_blank_test extends DokuWikiTest {
5 private $nope;
7 function test_blank() {
8 $tests = array(
9 // these are not blank
10 array('string', false),
11 array(1, false),
12 array(1.0, false),
13 array(0xff, false),
14 array(array('something'), false),
16 // these aren't either!
17 array('0', false),
18 array(' ', false),
19 array('0.0', false),
20 array(0, false),
21 array(0.0, false),
22 array(0x00, false),
23 array(true, false),
25 // but these are
26 array('', true),
27 array(array(), true),
28 array(null, true),
29 array(false, true),
30 array("\0", true)
33 foreach($tests as $test) {
34 $this->assertEquals($test[1], blank($test[0]), "using " . var_export($test[0], true));
38 function test_trim() {
39 $whitespace = " \t\r\n";
40 $this->assertFalse(blank($whitespace), "using default \$trim value");
41 $this->assertFalse(blank($whitespace, false), "using \$trim = false");
42 $this->assertTrue(blank($whitespace, true), "using \$trim = true");
45 function test_undefined() {
46 $undef = array();
47 $this->assertTrue(blank($var), "using undefined/unitialised variable");
48 $this->assertTrue(blank($undef['nope']), "using undefined array index");
49 $this->assertTrue(blank($this->nope), "using unset object property");