本文整理匯總了PHP中SimpleTest::popContext方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleTest::popContext方法的具體用法?PHP SimpleTest::popContext怎麽用?PHP SimpleTest::popContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleTest
的用法示例。
在下文中一共展示了SimpleTest::popContext方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Uses reflection to run every method within itself
* starting with the string "test" unless a method
* is specified.
* @param SimpleReporter $reporter Current test reporter.
* @return boolean True if all tests passed.
* @access public
*/
function run($reporter)
{
/*
Make sure that each (possibly nested!) test has its own fail/error/... queues, etc.
so that the expectXXX() functions work like you'ld expect, even when a test invokes
another test instance's run() method.
BREAKING CHANGE: We do know that tests might want to access the context which was used
to invoke the inner run(), but we MUST pop the context once the run() itself is
done to ensure that all expectXXX queues are aligned with the correct (nested)
tests. Hence, when a user wants access to the inner context's reporter, they should
ask the test instance, not the global scope. (See test/errors_test.php ~ line )
We do NOT pop context at the end of this call. Instead,
we use a heuristic to keep the chain/number of contexts to a minimum by popping
all /sub/contexts before we return, as those won't be accessible by grandparent
tests anyhow.
*/
$this->running = true;
$context = SimpleTest::pushContext();
$context->setTest($this);
$context->setReporter($reporter);
$this->reporter = $reporter;
$started = false;
foreach ($this->getTests() as $method) {
if ($reporter->shouldInvoke($this->getLabel(), $method)) {
$this->skip();
if ($this->should_skip) {
break;
}
if (!$started) {
$reporter->paintCaseStart($this->getLabel());
$started = true;
}
$invoker = $this->reporter->createInvoker($this->createInvoker());
$invoker->before($method);
$invoker->invoke($method);
$invoker->after($method);
}
}
if ($started) {
$reporter->paintCaseEnd($this->getLabel());
}
//$context->setTest(null);
SimpleTest::popContext($context);
$this->running = false;
return $reporter->getStatus();
}