1*5b571377SAndreas Gohr<?php 2*5b571377SAndreas Gohr 3*5b571377SAndreas Gohrclass common_blank_test extends DokuWikiTest { 4*5b571377SAndreas Gohr 5*5b571377SAndreas Gohr private $nope; 6*5b571377SAndreas Gohr 7*5b571377SAndreas Gohr function test_blank() { 8*5b571377SAndreas Gohr $tests = array( 9*5b571377SAndreas Gohr // these are not blank 10*5b571377SAndreas Gohr array('string', false), 11*5b571377SAndreas Gohr array(1, false), 12*5b571377SAndreas Gohr array(1.0, false), 13*5b571377SAndreas Gohr array(0xff, false), 14*5b571377SAndreas Gohr array(array('something'), false), 15*5b571377SAndreas Gohr 16*5b571377SAndreas Gohr // these aren't either! 17*5b571377SAndreas Gohr array('0', false), 18*5b571377SAndreas Gohr array(' ', false), 19*5b571377SAndreas Gohr array('0.0', false), 20*5b571377SAndreas Gohr array(0, false), 21*5b571377SAndreas Gohr array(0.0, false), 22*5b571377SAndreas Gohr array(0x00, false), 23*5b571377SAndreas Gohr array(true, false), 24*5b571377SAndreas Gohr 25*5b571377SAndreas Gohr // but these are 26*5b571377SAndreas Gohr array('', true), 27*5b571377SAndreas Gohr array(array(), true), 28*5b571377SAndreas Gohr array(null, true), 29*5b571377SAndreas Gohr array(false, true), 30*5b571377SAndreas Gohr array("\0", true) 31*5b571377SAndreas Gohr ); 32*5b571377SAndreas Gohr 33*5b571377SAndreas Gohr foreach($tests as $test) { 34*5b571377SAndreas Gohr $this->assertEquals($test[1], blank($test[0]), "using " . var_export($test[0], true)); 35*5b571377SAndreas Gohr } 36*5b571377SAndreas Gohr } 37*5b571377SAndreas Gohr 38*5b571377SAndreas Gohr function test_trim() { 39*5b571377SAndreas Gohr $blank = " "; 40*5b571377SAndreas Gohr $this->assertFalse(blank($blank)); 41*5b571377SAndreas Gohr $this->assertTrue(blank($blank, true)); 42*5b571377SAndreas Gohr } 43*5b571377SAndreas Gohr 44*5b571377SAndreas Gohr function test_undefindex() { 45*5b571377SAndreas Gohr $undef = array(); 46*5b571377SAndreas Gohr $this->assertTrue(blank($undef['nope'])); 47*5b571377SAndreas Gohr $this->assertTrue(blank($this->nope)); 48*5b571377SAndreas Gohr } 49*5b571377SAndreas Gohr 50*5b571377SAndreas Gohr} 51