本文整理匯總了PHP中Cake\Error\Debugger::excerpt方法的典型用法代碼示例。如果您正苦於以下問題:PHP Debugger::excerpt方法的具體用法?PHP Debugger::excerpt怎麽用?PHP Debugger::excerpt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cake\Error\Debugger
的用法示例。
在下文中一共展示了Debugger::excerpt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testExcerpt
/**
* test Excerpt writing
*
* @return void
*/
public function testExcerpt()
{
$result = Debugger::excerpt(__FILE__, __LINE__ - 1, 2);
$this->assertTrue(is_array($result));
$this->assertCount(5, $result);
$this->assertRegExp('/function(.+)testExcerpt/', $result[1]);
$result = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($result));
$this->assertCount(4, $result);
$this->skipIf(defined('HHVM_VERSION'), 'HHVM does not highlight php code');
$pattern = '/<code>.*?<span style\\="color\\: \\#\\d+">.*?<\\?php/';
$this->assertRegExp($pattern, $result[0]);
$result = Debugger::excerpt(__FILE__, 11, 2);
$this->assertCount(5, $result);
$pattern = '/<span style\\="color\\: \\#\\d{6}">\\*<\\/span>/';
$this->assertRegExp($pattern, $result[0]);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
$result = Debugger::excerpt(__FILE__, __LINE__, 5);
$this->assertCount(11, $result);
$this->assertContains('Debugger', $result[5]);
$this->assertContains('excerpt', $result[5]);
$this->assertContains('__FILE__', $result[5]);
}
示例2: testExcerpt
/**
* test Excerpt writing
*
* @return void
*/
public function testExcerpt()
{
$result = Debugger::excerpt(__FILE__, __LINE__, 2);
$this->assertTrue(is_array($result));
$this->assertEquals(5, count($result));
$this->assertRegExp('/function(.+)testExcerpt/', $result[1]);
$result = Debugger::excerpt(__FILE__, 2, 2);
$this->assertTrue(is_array($result));
$this->assertEquals(4, count($result));
$pattern = '/<code>.*?<span style\\="color\\: \\#\\d+">.*?<\\?php/';
$this->assertRegExp($pattern, $result[0]);
$result = Debugger::excerpt(__FILE__, 11, 2);
$this->assertEquals(5, count($result));
$pattern = '/<span style\\="color\\: \\#\\d{6}">\\*<\\/span>/';
$this->assertRegExp($pattern, $result[0]);
$return = Debugger::excerpt('[internal]', 2, 2);
$this->assertTrue(empty($return));
}