|
|
@@ -312,55 +312,55 @@ class DebuggerTest extends TestCase
|
|
|
$result = Debugger::exportVar($View);
|
|
|
$expected = <<<TEXT
|
|
|
object(Cake\View\View) id:0 {
|
|
|
- Html => object(Cake\View\Helper\HtmlHelper) id:1 {}
|
|
|
- Form => object(Cake\View\Helper\FormHelper) id:2 {}
|
|
|
- int => (int) 2
|
|
|
- float => (float) 1.333
|
|
|
- string => ' '
|
|
|
- [protected] _helpers => object(Cake\View\HelperRegistry) id:3 {}
|
|
|
- [protected] Blocks => object(Cake\View\ViewBlock) id:4 {}
|
|
|
- [protected] plugin => null
|
|
|
- [protected] name => ''
|
|
|
- [protected] helpers => [
|
|
|
- (int) 0 => 'Html',
|
|
|
- (int) 1 => 'Form'
|
|
|
- ]
|
|
|
- [protected] templatePath => null
|
|
|
- [protected] template => null
|
|
|
- [protected] layout => 'default'
|
|
|
- [protected] layoutPath => ''
|
|
|
- [protected] autoLayout => true
|
|
|
- [protected] viewVars => []
|
|
|
- [protected] _ext => '.php'
|
|
|
- [protected] subDir => ''
|
|
|
- [protected] theme => null
|
|
|
- [protected] request => object(Cake\Http\ServerRequest) id:5 {}
|
|
|
- [protected] response => object(Cake\Http\Response) id:6 {}
|
|
|
- [protected] elementCache => 'default'
|
|
|
- [protected] _passedVars => [
|
|
|
- (int) 0 => 'viewVars',
|
|
|
- (int) 1 => 'autoLayout',
|
|
|
- (int) 2 => 'helpers',
|
|
|
- (int) 3 => 'template',
|
|
|
- (int) 4 => 'layout',
|
|
|
- (int) 5 => 'name',
|
|
|
- (int) 6 => 'theme',
|
|
|
- (int) 7 => 'layoutPath',
|
|
|
- (int) 8 => 'templatePath',
|
|
|
- (int) 9 => 'plugin'
|
|
|
- ]
|
|
|
- [protected] _defaultConfig => []
|
|
|
- [protected] _paths => []
|
|
|
- [protected] _pathsForPlugin => []
|
|
|
- [protected] _parents => []
|
|
|
- [protected] _current => null
|
|
|
- [protected] _currentType => ''
|
|
|
- [protected] _stack => []
|
|
|
- [protected] _viewBlockClass => 'Cake\View\ViewBlock'
|
|
|
- [protected] _eventManager => object(Cake\Event\EventManager) id:7 {}
|
|
|
- [protected] _eventClass => 'Cake\Event\Event'
|
|
|
- [protected] _config => []
|
|
|
- [protected] _configInitialized => true
|
|
|
+ Html => object(Cake\View\Helper\HtmlHelper) id:1 {}
|
|
|
+ Form => object(Cake\View\Helper\FormHelper) id:2 {}
|
|
|
+ int => (int) 2
|
|
|
+ float => (float) 1.333
|
|
|
+ string => ' '
|
|
|
+ [protected] _helpers => object(Cake\View\HelperRegistry) id:3 {}
|
|
|
+ [protected] Blocks => object(Cake\View\ViewBlock) id:4 {}
|
|
|
+ [protected] plugin => null
|
|
|
+ [protected] name => ''
|
|
|
+ [protected] helpers => [
|
|
|
+ (int) 0 => 'Html',
|
|
|
+ (int) 1 => 'Form'
|
|
|
+ ]
|
|
|
+ [protected] templatePath => null
|
|
|
+ [protected] template => null
|
|
|
+ [protected] layout => 'default'
|
|
|
+ [protected] layoutPath => ''
|
|
|
+ [protected] autoLayout => true
|
|
|
+ [protected] viewVars => []
|
|
|
+ [protected] _ext => '.php'
|
|
|
+ [protected] subDir => ''
|
|
|
+ [protected] theme => null
|
|
|
+ [protected] request => object(Cake\Http\ServerRequest) id:5 {}
|
|
|
+ [protected] response => object(Cake\Http\Response) id:6 {}
|
|
|
+ [protected] elementCache => 'default'
|
|
|
+ [protected] _passedVars => [
|
|
|
+ (int) 0 => 'viewVars',
|
|
|
+ (int) 1 => 'autoLayout',
|
|
|
+ (int) 2 => 'helpers',
|
|
|
+ (int) 3 => 'template',
|
|
|
+ (int) 4 => 'layout',
|
|
|
+ (int) 5 => 'name',
|
|
|
+ (int) 6 => 'theme',
|
|
|
+ (int) 7 => 'layoutPath',
|
|
|
+ (int) 8 => 'templatePath',
|
|
|
+ (int) 9 => 'plugin'
|
|
|
+ ]
|
|
|
+ [protected] _defaultConfig => []
|
|
|
+ [protected] _paths => []
|
|
|
+ [protected] _pathsForPlugin => []
|
|
|
+ [protected] _parents => []
|
|
|
+ [protected] _current => null
|
|
|
+ [protected] _currentType => ''
|
|
|
+ [protected] _stack => []
|
|
|
+ [protected] _viewBlockClass => 'Cake\View\ViewBlock'
|
|
|
+ [protected] _eventManager => object(Cake\Event\EventManager) id:7 {}
|
|
|
+ [protected] _eventClass => 'Cake\Event\Event'
|
|
|
+ [protected] _config => []
|
|
|
+ [protected] _configInitialized => true
|
|
|
}
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -372,8 +372,8 @@ TEXT;
|
|
|
$result = Debugger::exportVar($data);
|
|
|
$expected = <<<TEXT
|
|
|
[
|
|
|
- (int) 1 => 'Index one',
|
|
|
- (int) 5 => 'Index five'
|
|
|
+ (int) 1 => 'Index one',
|
|
|
+ (int) 5 => 'Index five'
|
|
|
]
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -386,9 +386,9 @@ TEXT;
|
|
|
$result = Debugger::exportVar($data, 1);
|
|
|
$expected = <<<TEXT
|
|
|
[
|
|
|
- 'key' => [
|
|
|
- [maximum depth reached]
|
|
|
- ]
|
|
|
+ 'key' => [
|
|
|
+ '' => [maximum depth reached]
|
|
|
+ ]
|
|
|
]
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -403,7 +403,7 @@ TEXT;
|
|
|
$file = fopen('php://output', 'w');
|
|
|
fclose($file);
|
|
|
$result = Debugger::exportVar($file);
|
|
|
- $this->assertTextEquals('unknown', $result);
|
|
|
+ $this->assertTextEquals('(unknown)', $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -423,11 +423,11 @@ TEXT;
|
|
|
$result = Debugger::exportVar($data);
|
|
|
$expected = <<<TEXT
|
|
|
[
|
|
|
- 'nothing' => '',
|
|
|
- 'null' => null,
|
|
|
- 'false' => false,
|
|
|
- 'szero' => '0',
|
|
|
- 'zero' => (int) 0
|
|
|
+ 'nothing' => '',
|
|
|
+ 'null' => null,
|
|
|
+ 'false' => false,
|
|
|
+ 'szero' => '0',
|
|
|
+ 'zero' => (int) 0
|
|
|
]
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -451,11 +451,11 @@ TEXT;
|
|
|
$result = Debugger::exportVar($parent, 6);
|
|
|
$expected = <<<TEXT
|
|
|
object(stdClass) id:0 {
|
|
|
- name => 'cake'
|
|
|
- child => object(stdClass) id:1 {
|
|
|
- name => 'php'
|
|
|
- child => object(stdClass) id:0 {}
|
|
|
- }
|
|
|
+ name => 'cake'
|
|
|
+ child => object(stdClass) id:1 {
|
|
|
+ name => 'php'
|
|
|
+ child => object(stdClass) id:0 {}
|
|
|
+ }
|
|
|
}
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -535,18 +535,18 @@ TEXT;
|
|
|
$close = "\n\n";
|
|
|
$expected = <<<TEXT
|
|
|
{$open}[
|
|
|
- 'People' => [
|
|
|
- (int) 0 => [
|
|
|
- 'name' => 'joeseph',
|
|
|
- 'coat' => 'technicolor',
|
|
|
- 'hair_color' => 'brown'
|
|
|
- ],
|
|
|
- (int) 1 => [
|
|
|
- 'name' => 'Shaft',
|
|
|
- 'coat' => 'black',
|
|
|
- 'hair' => 'black'
|
|
|
- ]
|
|
|
- ]
|
|
|
+ 'People' => [
|
|
|
+ (int) 0 => [
|
|
|
+ 'name' => 'joeseph',
|
|
|
+ 'coat' => 'technicolor',
|
|
|
+ 'hair_color' => 'brown'
|
|
|
+ ],
|
|
|
+ (int) 1 => [
|
|
|
+ 'name' => 'Shaft',
|
|
|
+ 'coat' => 'black',
|
|
|
+ 'hair' => 'black'
|
|
|
+ ]
|
|
|
+ ]
|
|
|
]{$close}
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -557,9 +557,9 @@ TEXT;
|
|
|
|
|
|
$expected = <<<TEXT
|
|
|
{$open}[
|
|
|
- 'People' => [
|
|
|
- [maximum depth reached]
|
|
|
- ]
|
|
|
+ 'People' => [
|
|
|
+ '' => [maximum depth reached]
|
|
|
+ ]
|
|
|
]{$close}
|
|
|
TEXT;
|
|
|
$this->assertTextEquals($expected, $result);
|
|
|
@@ -586,14 +586,14 @@ TEXT;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Test that exportVar() doesn't loop through recursive structures.
|
|
|
+ * Test that exportVar() will stop traversing recursive arrays like GLOBALS.
|
|
|
*
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testExportVarRecursion()
|
|
|
{
|
|
|
$output = Debugger::exportVar($GLOBALS);
|
|
|
- $this->assertStringContainsString("'GLOBALS' => [recursion]", $output);
|
|
|
+ $this->assertRegExp("/'GLOBALS' => \[\s+'' \=\> \[maximum depth reached\]/", $output);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -623,10 +623,8 @@ TEXT;
|
|
|
$result = Debugger::exportVar($object, 2);
|
|
|
$expected = <<<eos
|
|
|
object(TestApp\Error\Thing\DebuggableThing) id:0 {
|
|
|
-
|
|
|
- 'foo' => 'bar',
|
|
|
- 'inner' => object(TestApp\Error\Thing\DebuggableThing) id:1 {}
|
|
|
-
|
|
|
+ 'foo' => 'bar'
|
|
|
+ 'inner' => object(TestApp\Error\Thing\DebuggableThing) id:1 {}
|
|
|
}
|
|
|
eos;
|
|
|
$this->assertEquals($expected, $result);
|
|
|
@@ -656,7 +654,7 @@ eos;
|
|
|
{
|
|
|
Debugger::setOutputMask(['password' => '[**********]']);
|
|
|
$result = Debugger::exportVar(['password' => 'pass1234']);
|
|
|
- $expected = "['password'=>[**********]]";
|
|
|
+ $expected = "['password'=>'[**********]']";
|
|
|
$this->assertEquals($expected, preg_replace('/\s+/', '', $result));
|
|
|
}
|
|
|
|
|
|
@@ -670,7 +668,7 @@ eos;
|
|
|
Debugger::setOutputMask(['password' => '[**********]']);
|
|
|
$object = new SecurityThing();
|
|
|
$result = Debugger::exportVar($object);
|
|
|
- $expected = 'object(TestApp\\Error\\Thing\\SecurityThing)id:0{password=>[**********]}';
|
|
|
+ $expected = "object(TestApp\\Error\\Thing\\SecurityThing)id:0{password=>'[**********]'}";
|
|
|
$this->assertEquals($expected, preg_replace('/\s+/', '', $result));
|
|
|
}
|
|
|
|