本文整理汇总了PHP中SimpleErrorQueue::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleErrorQueue::instance方法的具体用法?PHP SimpleErrorQueue::instance怎么用?PHP SimpleErrorQueue::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleErrorQueue
的用法示例。
在下文中一共展示了SimpleErrorQueue::instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTrappedErrorPLacedInQueue
function testTrappedErrorPLacedInQueue() {
$queue = &SimpleErrorQueue::instance();
$this->assertFalse($queue->extract());
trigger_error('Ouch!');
list($severity, $message, $file, $line, $globals) = $queue->extract();
$this->assertEqual($message, 'Ouch!');
$this->assertEqual($file, __FILE__);
$this->assertFalse($queue->extract());
}
示例2: invoke
function invoke($method)
{
set_error_handler('simpleTestErrorHandler');
parent::invoke($method);
$queue =& SimpleErrorQueue::instance();
while (list($severity, $message, $file, $line, $globals) = $queue->extract()) {
$test_case =& $this->getTestCase();
$test_case->error($severity, $message, $file, $line, $globals);
}
restore_error_handler();
}
示例3: simpleTestErrorHandler
function simpleTestErrorHandler($severity, $message, $filename, $line, $super_globals)
{
if ($severity = $severity & error_reporting()) {
restore_error_handler();
if (ini_get('log_errors')) {
$label = SimpleErrorQueue::getSeverityAsString($severity);
error_log("{$label}: {$message} in {$filename} on line {$line}");
}
$queue =& SimpleErrorQueue::instance();
$queue->add($severity, $message, $filename, $line, $super_globals);
set_error_handler('simpleTestErrorHandler');
}
}
示例4: swallowErrors
function swallowErrors()
{
$queue =& SimpleErrorQueue::instance();
$queue->clear();
}
示例5: assertErrorPattern
/**
* Confirms that an error has occoured and
* that the error text matches a Perl regular
* expression.
* @param string $expected Perl regular expresion to
* match against.
* @param string $message Message to display.
* @return boolean True on pass
* @access public
*/
function assertErrorPattern($pattern, $message = "%s")
{
$queue =& SimpleErrorQueue::instance();
if ($queue->isEmpty()) {
$this->fail(sprintf($message, "Expected error not found"));
return;
}
list($severity, $content, $file, $line, $globals) = $queue->extract();
$severity = SimpleErrorQueue::getSeverityAsString($severity);
return $this->assertTrue((bool) preg_match($pattern, $content), "Expected pattern match [{$pattern}] in PHP error [{$content}] severity [{$severity}] in [{$file}] line [{$line}]");
}
示例6: assertError
/**
* Confirms that an error has occoured and
* optionally that the error text matches exactly.
* @param string $expected Expected error text or
* false for no check.
* @param string $message Message to display.
* @return boolean True on pass
* @access public
*/
function assertError($expected = false, $message = "%s")
{
$queue =& SimpleErrorQueue::instance();
if ($queue->isEmpty()) {
$this->fail(sprintf($message, "Expected error not found"));
return;
}
list($severity, $content, $file, $line, $globals) = $queue->extract();
$severity = SimpleErrorQueue::getSeverityAsString($severity);
if (!$expected) {
return $this->pass("Captured a PHP error of [{$content}] severity [{$severity}] in [{$file}] line [{$line}] -> %s");
}
$expected = $this->_coerceToExpectation($expected);
return $this->assert($expected, $content, "Expected PHP error [{$content}] severity [{$severity}] in [{$file}] line [{$line}] -> %s");
}
示例7: simpleTestErrorHandler
/**
* Error handler that simply stashes any
* errors into the global error queue.
* @param $severity PHP error code.
* @param $message Text of error.
* @param $filename File error occoured in.
* @param $line Line number of error.
* @param $super_globals Hash of PHP super global arrays.
* @static
* @access public
*/
function simpleTestErrorHandler($severity, $message, $filename, $line, $super_globals) {
restore_error_handler();
if ($severity = $severity & error_reporting()) {
$queue = &SimpleErrorQueue::instance();
$queue->add($severity, $message, $filename, $line, $super_globals);
}
set_error_handler('simpleTestErrorHandler');
}