git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7761 3807eeeb-6ff5-0310-8944-8be069107fe0

This commit is contained in:
mark_story 2008-10-18 01:23:33 +00:00
parent f875c0098b
commit 66cfeee8c7
2 changed files with 18 additions and 0 deletions

View file

@ -336,6 +336,9 @@ class Debugger extends Object {
*/
function excerpt($file, $line, $context = 2) {
$data = $lines = array();
if (!file_exists($file)) {
return array();
}
$data = @explode("\n", file_get_contents($file));
if (empty($data) || !isset($data[$line])) {

View file

@ -64,6 +64,21 @@ class DebuggerTest extends CakeTestCase {
$debugger = new Debugger();
$this->assertEqual(ini_get('docref_root'), 'http://php.net/');
}
/**
* test Excerpt writing
*
* @return void
**/
function testExcerpt() {
$return = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($return));
$this->assertEqual(count($return), 4);
$this->assertPattern('#/* SVN FILE: \$Id: debugger.test.php#', $return[1]);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
}
/**
* testOutput method
*