本文整理汇总了PHP中SimpleTest::pushContext方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleTest::pushContext方法的具体用法?PHP SimpleTest::pushContext怎么用?PHP SimpleTest::pushContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleTest
的用法示例。
在下文中一共展示了SimpleTest::pushContext方法的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();
}