Permalink
Browse files

Updated test for debug

It now detects being called from CLI
  • Loading branch information...
markomarkovic committed Nov 5, 2011
1 parent c7363bb commit 4e702b2faefee3604a121bfd248ef5021be703aa
Showing with 71 additions and 11 deletions.
  1. +71 −11 lib/Cake/Test/Case/BasicsTest.php
@@ -683,29 +683,53 @@ public function testDebug() {
ob_start();
debug('this-is-a-test');
$result = ob_get_clean();
$expected = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
this-is-a-test
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
this-is-a-test
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEqual($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>');
$result = ob_get_clean();
$expected = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
&lt;div&gt;this-is-a-test&lt;/div&gt;
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
<div>this-is-a-test</div>
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEqual($expected, $result);
ob_start();
@@ -753,43 +777,79 @@ public function testDebug() {
ob_start();
debug('<div>this-is-a-test</div>', null);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
&lt;div&gt;this-is-a-test&lt;/div&gt;
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
<div>this-is-a-test</div>
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEqual($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', null, true);
debug('<div>this-is-a-test</div>', null);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%d</strong>)</span>
<pre class="cake-debug">
&lt;div&gt;this-is-a-test&lt;/div&gt;
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expectedText = <<<EXPECTED
%s (line %d)
########## DEBUG ##########
<div>this-is-a-test</div>
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEqual($expected, $result);
ob_start();
debug('<div>this-is-a-test</div>', null, false);
$result = ob_get_clean();
$expected = <<<EXPECTED
$expectedHtml = <<<EXPECTED
<div class="cake-debug-output">
<pre class="cake-debug">
&lt;div&gt;this-is-a-test&lt;/div&gt;
</pre>
</div>
EXPECTED;
$expected = sprintf($expected, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 10);
$expectedText = <<<EXPECTED
########## DEBUG ##########
<div>this-is-a-test</div>
###########################
EXPECTED;
if (php_sapi_name() == 'cli') {
$expected = sprintf($expectedText, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 19);
} else {
$expected = sprintf($expectedHtml, substr(__FILE__, strlen(ROOT) + 1), __LINE__ - 21);
}
$this->assertEqual($expected, $result);
ob_start();

0 comments on commit 4e702b2

Please sign in to comment.