mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7761 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
f875c0098b
commit
66cfeee8c7
2 changed files with 18 additions and 0 deletions
|
@ -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])) {
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue