Skip to content
Permalink
Browse files

debug() may output path that is incorrectly truncated

This happens when debug is called in core source files that resides in
a different directory to the app.
  • Loading branch information...
rchavik committed May 28, 2012
1 parent fb0cc50 commit 483d7124ddf0c8794f3999fbd68979a2435593bb
Showing with 13 additions and 12 deletions.
  1. +12 −11 lib/Cake/Test/Case/BasicsTest.php
  2. +1 −1 lib/Cake/basics.php
@@ -691,7 +691,8 @@ public function testDebug() {
'this-is-a-test'
###########################
EXPECTED;
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT)), __LINE__ - 8);
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 8);
$this->assertEquals($expected, $result);
ob_start();
@@ -705,7 +706,7 @@ public function testDebug() {
</pre>
</div>
EXPECTED;
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT)), __LINE__ - 10);
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 10);
$this->assertEquals($expected, $result);
ob_start();
@@ -719,7 +720,7 @@ public function testDebug() {
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT)), __LINE__ - 10);
$expected = sprintf($expected, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 10);
$this->assertEquals($expected, $result);
ob_start();
@@ -733,7 +734,7 @@ public function testDebug() {
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT)), __LINE__ - 10);
$expected = sprintf($expected, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 10);
$this->assertEquals($expected, $result);
ob_start();
@@ -754,9 +755,9 @@ public function testDebug() {
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT)), __LINE__ - 17);
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 17);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT)), __LINE__ - 19);
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19);
}
$this->assertEquals($expected, $result);
@@ -778,9 +779,9 @@ public function testDebug() {
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT)), __LINE__ - 17);
$expected = sprintf($expectedText, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 17);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT)), __LINE__ - 19);
$expected = sprintf($expectedHtml, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 19);
}
$this->assertEquals($expected, $result);
@@ -793,7 +794,7 @@ public function testDebug() {
'<div>this-is-a-test</div>'
###########################
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT)), __LINE__ - 8);
$expected = sprintf($expected, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 8);
$this->assertEquals($expected, $result);
ob_start();
@@ -805,7 +806,7 @@ public function testDebug() {
'<div>this-is-a-test</div>'
###########################
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT)), __LINE__ - 8);
$expected = sprintf($expected, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 8);
$this->assertEquals($expected, $result);
ob_start();
@@ -817,7 +818,7 @@ public function testDebug() {
'<div>this-is-a-test</div>'
###########################
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT)), __LINE__ - 8);
$expected = sprintf($expected, str_replace(CAKE_CORE_INCLUDE_PATH, '', __FILE__), __LINE__ - 8);
$this->assertEquals($expected, $result);
}
@@ -77,7 +77,7 @@ function debug($var = false, $showHtml = null, $showFrom = true) {
$lineInfo = '';
if ($showFrom) {
$trace = Debugger::trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
$file = substr($trace[0]['file'], strlen(ROOT));
$file = str_replace(array(CAKE_CORE_INCLUDE_PATH, ROOT), '', $trace[0]['file']);
$line = $trace[0]['line'];
}
$html = <<<HTML

0 comments on commit 483d712

Please sign in to comment.
You can’t perform that action at this time.