本文整理汇总了PHP中SimpleTest::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleTest::getContext方法的具体用法?PHP SimpleTest::getContext怎么用?PHP SimpleTest::getContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleTest
的用法示例。
在下文中一共展示了SimpleTest::getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
function run($reporter)
{
$context = SimpleTest::getContext();
$context->setTest($this);
$context->setReporter($reporter);
$this->reporter = $reporter;
$this->reporter->paintCaseStart($this->getLabel());
if ($this->needPDO) {
$this->reporter->makeDry(!$this->assertTrue(class_exists('PDO', false), 'PDO does not exists ! You should install PDO because tests need it.'));
}
$this->setUpRun();
foreach ($this->getTests() as $method) {
if ($this->reporter->shouldInvoke($this->getLabel(), $method)) {
$this->skip();
if ($this->shouldSkip()) {
break;
}
$invoker = $this->reporter->createInvoker($this->createInvoker());
$invoker->before($method);
$invoker->invoke($method);
$invoker->after($method);
}
}
$this->tearDownRun();
$this->reporter->paintCaseEnd($this->getLabel());
unset($this->reporter);
return $reporter->getStatus();
}
示例2: tests_have_run
/**
* Checks the current test context to see if a test has
* ever been run.
* @return boolean True if tests have run.
*/
function tests_have_run()
{
if ($context = SimpleTest::getContext()) {
return (bool) $context->getTest();
}
return false;
}
示例3: createErrorQueue
/**
* Wires up the error queue for a single test.
* @return SimpleErrorQueue Queue connected to the test.
* @access private
*/
protected function createErrorQueue()
{
$context = SimpleTest::getContext();
$test = $this->getTestCase();
$queue = $context->get('SimpleErrorQueue');
$queue->setTestCase($test);
return $queue;
}
示例4: shouldPaintMethod
/**
* @param string $testName
*/
protected function shouldPaintMethod($testName)
{
$testCase = SimpleTest::getContext()->getTest();
if (!$testCase instanceof CakeTestCase) {
return true;
}
return !in_array(strtolower($testName), $testCase->methods);
}
示例5: shouldInvoke
/**
* @param string $testCase
* @param string $method
* @return boolean
*/
public function shouldInvoke($testCase, $method)
{
$test = SimpleTest::getContext()->getTest();
if ($test instanceof CakeTestCase && in_array(strtolower($method), $test->methods)) {
return true;
}
return parent::shouldInvoke($testCase, $method);
}
示例6:
/**
* Wires up the error queue for a single test.
*
* @return SimpleErrorQueue Queue connected to the test.
*/
public function &_createErrorQueue()
{
$context =& SimpleTest::getContext();
$test =& $this->getTestCase();
$queue =& $context->get('SimpleErrorQueue');
$queue->setTestCase($test);
return $queue;
}
示例7: invoke
/**
* Invokes a test method and dispatches any
* untrapped errors. Called back from
* the visiting runner.
* @param string $method Test method to call.
* @access public
*/
function invoke($method)
{
$context =& SimpleTest::getContext();
$queue =& $context->get('SimpleErrorQueue');
$queue->setTestCase($this->GetTestCase());
set_error_handler('SimpleTestErrorHandler');
parent::invoke($method);
while (list($severity, $message, $file, $line) = $queue->extract()) {
$severity = SimpleErrorQueue::getSeverityAsString($severity);
$test =& $this->getTestCase();
$test->error($severity, $message, $file, $line);
}
restore_error_handler();
}
示例8: invoke
/**
* Lists rather then invokes a test method. Consequently,
* we do not invoke the setUp() and tearDown() calls either.
* @param string $method Test method to call.
* @access public
*/
function invoke($method)
{
$context = SimpleTest::getContext();
$test = $this->getTestCase();
// $context->getTest();
$reporter = $context->getReporter();
// use 'user signal' as the way to render the list entry:
$case = get_class($test);
if ($case != $test->getLabel()) {
$case = sprintf("%s [%s]", $case, $test->getLabel());
}
$show_breadcrumb = $reporter->includeBreadCrumb(false);
$reporter->paintSignal("Test", sprintf("Case: %s | Method: %s", $case, $method));
$reporter->includeBreadCrumb($show_breadcrumb);
}
示例9: invoke
/**
* Invokes a test method whilst trapping expected
* exceptions. Any left over unthrown exceptions
* are then reported as failures.
* @param string $method Test method to call.
*/
function invoke($method)
{
$trap = SimpleTest::getContext()->get('SimpleExceptionTrap');
$trap->clear();
try {
parent::invoke($method);
} catch (Exception $exception) {
if (!$trap->isExpected($this->getTestCase(), $exception)) {
$this->getTestCase()->exception($exception);
}
$trap->clear();
}
if ($message = $trap->getOutstanding()) {
$this->getTestCase()->fail($message);
}
}
示例10: send
public function send($v1, $v2)
{
// test for context
$context = SimpleTest::getContext();
$test = $context->getTest();
$mock = $this->mock;
foreach ($this->_expected_context as $key => $value) {
$test->assertEqual($value, $this->_context->get($key));
}
$step = $mock->getCallCount('send');
if (isset($this->_expected_context_at[$step])) {
foreach ($this->_expected_context_at[$step] as $key => $value) {
$test->assertEqual($value, $this->_context->get($key));
}
}
// boilerplate mock code, does not have return value or references
$args = func_get_args();
$mock->invoke('send', $args);
}
示例11: invoke
/**
* Invokes a test method whilst trapping expected
* exceptions. Any left over unthrown exceptions
* are then reported as failures.
*
* @param string $method Test method to call.
*/
public function invoke($method)
{
$trap = SimpleTest::getContext()->get('SimpleExceptionTrap');
$trap->clear();
try {
$has_thrown = false;
parent::invoke($method);
} catch (Exception $exception) {
$has_thrown = true;
if (!$trap->isExpected($this->getTestCase(), $exception)) {
$this->getTestCase()->exception($exception);
}
$trap->clear();
}
if ($message = $trap->getOutstanding()) {
$this->getTestCase()->fail($message);
}
if ($has_thrown) {
try {
parent::getTestCase()->tearDown();
} catch (Exception $e) {
}
}
}
示例12: testQueueStartsEmpty
public function testQueueStartsEmpty()
{
$context = SimpleTest::getContext();
$queue = $context->get('SimpleErrorQueue');
$this->assertFalse($queue->extract());
}
示例13: _getCurrentTestCase
/**
* Finds currently running test.
* @return SimpeTestCase Current test case.
* @access protected
*/
function _getCurrentTestCase()
{
$context =& SimpleTest::getContext();
return $context->getTest();
}
示例14: getCurrentTestCase
/**
* Finds currently running test.
* @return SimpeTestCase Current test case.
*/
protected function getCurrentTestCase()
{
return SimpleTest::getContext()->getTest();
}
示例15: paintMethodStart
/**
* @param string $testName
*/
public function paintMethodStart($testName)
{
parent::paintMethodStart($testName);
$this->xmlWriter->startTestCase($testName, SimpleTest::getContext()->getTest());
$this->methodStartTime = microtime(true);
$this->assertionCount = 0;
}