oWithDebuginfo = $this->getMock(Geocode::class, array('debugInfo')); $this->oWithDebuginfo->method('debugInfo') ->willReturn(array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3')); $this->oWithToString = $this->getMock(Geocode::class, array('__toString')); $this->oWithToString->method('__toString')->willReturn('me as string'); } public function testPrintVar() { $this->expectOutputString(<<Var0:
Var1:  True
Var2:  False
Var3:  0
Var4:  'String'
Var5:  0 => 'one'
       1 => 'two'
       2 => 'three'
Var6:  'key' => 'value'
       'key2' => 'value2'
Var7:  me as string
Var8:  'value', 'value2'
EOT ); Debug::printVar('Var0', null); Debug::printVar('Var1', true); Debug::printVar('Var2', false); Debug::printVar('Var3', 0); Debug::printVar('Var4', 'String'); Debug::printVar('Var5', array('one', 'two', 'three')); Debug::printVar('Var6', array('key' => 'value', 'key2' => 'value2')); Debug::printVar('Var7', $this->oWithToString); Debug::printVar('Var8', Debug::fmtArrayVals(array('key' => 'value', 'key2' => 'value2'))); } public function testDebugArray() { $this->expectOutputString(<<Arr0: 'null'
Arr1:  'key1' => 'val1'
       'key2' => 'val2'
       'key3' => 'val3'
EOT ); Debug::printDebugArray('Arr0', null); Debug::printDebugArray('Arr1', $this->oWithDebuginfo); } public function testPrintDebugTable() { $this->expectOutputString(<<Table1:
Table2:
Table3:
0 1
'one'
'two'
'three'
'four'
Table4:
key1 key2 key3
'val1'
'val2'
'val3'
EOT ); Debug::printDebugTable('Table1', null); Debug::printDebugTable('Table2', array()); // Numeric headers Debug::printDebugTable('Table3', array(array('one', 'two'), array('three', 'four'))); // Associate array Debug::printDebugTable('Table4', array($this->oWithDebuginfo)); } public function testPrintGroupTable() { $this->expectOutputString(<<Table1:
Table2:
Table3:
Group key1 key2
group1
'val1'
'val2'
group1
'one'
'two'
group2
'val1'
'val2'
Table4:
Group key1 key2 key3
group1
'val1'
'val2'
'val3'
group1
'val1'
'val2'
'val3'
EOT ); Debug::printGroupTable('Table1', null); Debug::printGroupTable('Table2', array()); // header are taken from first group item, thus no key3 gets printed $aGroups = array( 'group1' => array( array('key1' => 'val1', 'key2' => 'val2'), array('key1' => 'one', 'key2' => 'two', 'unknown' => 1), ), 'group2' => array( array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'), ) ); Debug::printGroupTable('Table3', $aGroups); $aGroups = array( 'group1' => array($this->oWithDebuginfo, $this->oWithDebuginfo), ); Debug::printGroupTable('Table4', $aGroups); } }