* @copyright (c) 2008-2014 Kohana Team * @license http://kohanaframework.org/license */ class Kohana_DebugTest extends Unittest_TestCase { /** * Provides test data for test_debug() * * @return array */ public function provider_vars() { return array( // $thing, $expected array(array('foobar'), "
array(1) (\n 0 => string(6) \"foobar\"\n)"), ); } /** * Tests Debug::vars() * * @test * @dataProvider provider_vars * @covers Debug::vars * @param boolean $thing The thing to debug * @param boolean $expected Output for Debug::vars */ public function test_var($thing, $expected) { $this->assertEquals($expected, Debug::vars($thing)); } /** * Provides test data for testDebugPath() * * @return array */ public function provider_debug_path() { return array( array( SYSPATH.'classes'.DIRECTORY_SEPARATOR.'kohana'.EXT, 'SYSPATH'.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'kohana.php' ), array( SMDPATH.$this->dirSeparator('unittest/classes/kohana/unittest/runner').EXT, $this->dirSeparator('SMDPATH/unittest/classes/kohana/unittest/runner').EXT ), ); } /** * Tests Debug::path() * * @test * @dataProvider provider_debug_path * @covers Debug::path * @param boolean $path Input for Debug::path * @param boolean $expected Output for Debug::path */ public function test_debug_path($path, $expected) { $this->assertEquals($expected, Debug::path($path)); } /** * Provides test data for test_dump() * * @return array */ public function provider_dump() { return array( array('foobar', 128, 10, 'string(6) "foobar"'), array('foobar', 2, 10, 'string(6) "fo …"'), array(NULL, 128, 10, 'NULL'), array(TRUE, 128, 10, 'bool TRUE'), array(array('foobar'), 128, 10, "array(1) (\n 0 => string(6) \"foobar\"\n)"), array(new StdClass, 128, 10, "object stdClass(0)
{\n}
"),
array("fo\x6F\xFF\x00bar\x8F\xC2\xB110", 128, 10, 'string(10) "foobar±10"'),
array(array('level1' => array('level2' => array('level3' => array('level4' => array('value' => 'something'))))), 128, 4,
'array(1) (
"level1" => array(1) (
"level2" => array(1) (
"level3" => array(1) (
"level4" => array(1) (
...
)
)
)
)
)'),
);
}
/**
* Tests Debug::dump()
*
* @test
* @dataProvider provider_dump
* @covers Debug::dump
* @covers Debug::_dump
* @param object $exception exception to test
* @param string $expected expected output
*/
public function test_dump($input, $length, $limit, $expected)
{
$this->assertEquals($expected, Debug::dump($input, $length, $limit));
}
}