本文整理匯總了PHP中PHPUnit_Util_Test::describe方法的典型用法代碼示例。如果您正苦於以下問題:PHP PHPUnit_Util_Test::describe方法的具體用法?PHP PHPUnit_Util_Test::describe怎麽用?PHP PHPUnit_Util_Test::describe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PHPUnit_Util_Test
的用法示例。
在下文中一共展示了PHPUnit_Util_Test::describe方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: accept
/**
* @return boolean
*/
public function accept()
{
$test = $this->getInnerIterator()->current();
if ($test instanceof PHPUnit_Framework_TestSuite) {
return TRUE;
}
$tmp = PHPUnit_Util_Test::describe($test, FALSE);
if ($tmp[0] != '') {
$name = join('::', $tmp);
} else {
$name = $tmp[1];
}
return preg_match($this->filter, $name);
}
示例2: endTest
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
parent::endTest($test, $time);
if ($this->debug) {
foreach ($this->timeColors as $threshold => $color) {
if ($time >= $threshold) {
$timeColor = $color;
break;
}
}
$this->write(' ');
$this->writeWithColor($timeColor, '[' . number_format($time, 3) . 's]', false);
$this->write(' ');
$this->writeWithColor('fg-cyan', \PHPUnit_Util_Test::describe($test), true);
}
}
示例3: accept
/**
* @return bool
*/
public function accept()
{
$test = $this->getInnerIterator()->current();
if ($test instanceof PHPUnit_Framework_TestSuite) {
return TRUE;
}
$tmp = PHPUnit_Util_Test::describe($test, FALSE);
if ($tmp[0] != '') {
$name = implode('::', $tmp);
} else {
$name = $tmp[1];
}
$accepted = preg_match($this->filter, $name, $matches);
if ($accepted && isset($this->filterMax)) {
$set = end($matches);
$accepted = $set >= $this->filterMin && $set <= $this->filterMax;
}
return $accepted;
}
示例4: endTest
/**
* {@inheritdoc}
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
$test_name = \PHPUnit_Util_Test::describe($test);
if (!empty($test_name)) {
$this->test_name_status = sprintf("%s (%s)\n", $test_name, sprintf("%s ms", round($time * 1000)));
}
if (!$this->lastTestFailed) {
$this->writeProgress('.');
}
if ($test instanceof \PHPUnit_Framework_TestCase) {
$this->numAssertions += $test->getNumAssertions();
} elseif ($test instanceof \PHPUnit_Extensions_PhptTestCase) {
$this->numAssertions++;
}
$this->lastTestFailed = false;
if ($test instanceof \PHPUnit_Framework_TestCase) {
if (method_exists($this, 'hasExpectationOnOutput') && !$test->hasExpectationOnOutput()) {
$this->write($test->getActualOutput());
}
}
}
示例5: run
/**
* Runs the tests and collects their result in a TestResult.
*
* @param PHPUnit_Framework_TestResult $result
* @param mixed $filter
* @param array $groups
* @param array $excludeGroups
* @return PHPUnit_Framework_TestResult
* @throws InvalidArgumentException
*/
public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array())
{
if ($result === NULL) {
$result = $this->createResult();
}
try {
$this->setUp();
} catch (PHPUnit_Framework_SkippedTestSuiteError $e) {
$numTests = count($this);
for ($i = 0; $i < $numTests; $i++) {
$result->addFailure($this, $e, 0);
}
return $result;
}
$result->startTestSuite($this);
if (empty($groups)) {
$tests = $this->tests;
} else {
$tests = array();
foreach ($groups as $group) {
if (isset($this->groups[$group])) {
$tests = array_merge($tests, $this->groups[$group]);
}
}
}
foreach ($tests as $test) {
if ($result->shouldStop()) {
break;
}
if ($test instanceof PHPUnit_Framework_TestSuite) {
$test->setBackupGlobals($this->backupGlobals);
$test->setSharedFixture($this->sharedFixture);
$test->run($result, $filter, $groups, $excludeGroups);
} else {
$runTest = TRUE;
if ($filter !== FALSE) {
$tmp = PHPUnit_Util_Test::describe($test, FALSE);
if ($tmp[0] != '') {
$name = join('::', $tmp);
} else {
$name = $tmp[1];
}
if (preg_match($filter, $name) == 0) {
$runTest = FALSE;
}
}
if ($runTest && !empty($excludeGroups)) {
foreach ($this->groups as $_group => $_tests) {
if (@in_array($_group, $excludeGroups)) {
foreach ($_tests as $_test) {
if ($test === $_test) {
$runTest = FALSE;
break 2;
}
}
}
}
}
if ($runTest) {
if ($test instanceof PHPUnit_Framework_TestCase) {
$test->setBackupGlobals($this->backupGlobals);
$test->setSharedFixture($this->sharedFixture);
}
$this->runTest($test, $result);
}
}
}
$result->endTestSuite($this);
$this->tearDown();
return $result;
}
示例6: startTest
/**
* A test started.
*
* @param PHPUnit_Framework_Test $test
*/
public function startTest(PHPUnit_Framework_Test $test)
{
$this->currentTestName = PHPUnit_Util_Test::describe($test);
$this->currentTestPass = TRUE;
}
示例7: addTestNode
/**
* @param PHPUnit_Framework_Test $test
* @param string $color
* @access private
*/
private function addTestNode(PHPUnit_Framework_Test $test, $color)
{
$name = PHPUnit_Util_Test::describe($test, FALSE);
$this->graphs[$this->testSuiteLevel]->addNode($name[1], array('color' => $color, 'URL' => sprintf('%s-test.html#%s', PHPUnit_Util_Filesystem::getSafeFilename($name[0]), $name[1])), $this->testSuites[$this->testSuiteLevel]);
$this->graphs[$this->testSuiteLevel]->addEdge(array($this->testSuites[$this->testSuiteLevel] => $name[1]));
}
示例8: startTestSuite
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
$this->level++;
$name = PHPUnit_Util_Test::describe($suite);
if (empty($name)) {
//$name = get_class($suite);
$name = '-';
}
$this->suiteStack[] = $name;
}
示例9: startTest
/**
* A test started.
*
* @param PHPUnit_Framework_Test $test
*/
public function startTest(PHPUnit_Framework_Test $test)
{
$this->currentTestName = PHPUnit_Util_Test::describe($test);
$this->currentTestPass = TRUE;
$this->write("\n");
$this->write(sprintf('test started: %s', $this->currentTestName));
}
示例10: _getFilteredTests
private static function _getFilteredTests($testSuite, $filter, array $groups, array $excludeGroups)
{
$ret = array();
if (empty($groups)) {
$tests = $testSuite->tests;
} else {
$tests = array();
foreach ($groups as $group) {
if (isset($testSuite->groups[$group])) {
$tests = array_merge($tests, $testSuite->groups[$group]);
}
}
}
foreach ($tests as $test) {
if ($test instanceof PHPUnit_Framework_TestSuite) {
$ret = array_merge($ret, self::_getFilteredTests($test, $filter, $groups, $excludeGroups));
} else {
$runTest = TRUE;
if ($filter !== FALSE) {
$tmp = PHPUnit_Util_Test::describe($test, FALSE);
if ($tmp[0] != '') {
$name = join('::', $tmp);
} else {
$name = $tmp[1];
}
if (preg_match($filter, $name) == 0) {
$runTest = FALSE;
}
}
if ($runTest && !empty($excludeGroups)) {
foreach ($testSuite->groups as $_group => $_tests) {
if (in_array($_group, $excludeGroups)) {
foreach ($_tests as $_test) {
if ($test === $_test) {
$runTest = FALSE;
break 2;
}
}
}
}
}
if ($runTest) {
$ret[] = $test;
}
}
}
return $ret;
}
示例11: addTestNode
/**
* @param PHPUnit_Framework_Test $test
* @param string $color
* @access private
*/
private function addTestNode(PHPUnit_Framework_Test $test, $color)
{
$name = PHPUnit_Util_Test::describe($test, FALSE);
$this->graph->addNode($name[1], array('color' => $color), $this->testSuites[$this->testSuiteLevel]);
$this->graph->addEdge(array($this->testSuites[$this->testSuiteLevel] => $name[1]));
}
示例12: startTest
/**
* A test started.
*
* @param PHPUnit_Framework_Test $test
*/
public function startTest(PHPUnit_Framework_Test $test)
{
$this->currentTestName = PHPUnit_Util_Test::describe($test);
$this->currentTestPass = TRUE;
$this->write(array('event' => 'testStart', 'suite' => $this->currentTestSuiteName, 'test' => $this->currentTestName));
}
示例13: getTests
/**
* @param PHPUnit_Framework_TestResult $result
* @param PHPUnit_Framework_TestSuite $testSuite
* @return array
* @access protected
* @since Method available since Release 3.0.0
*/
protected static function getTests(PHPUnit_Framework_TestResult $result, PHPUnit_Framework_TestSuite $testSuite = NULL)
{
if ($testSuite === NULL) {
$testSuite = $result->topTestSuite();
}
$tests = array();
foreach ($testSuite->tests() as $test) {
if ($test instanceof PHPUnit_Framework_TestSuite) {
$tests = array_merge($tests, self::getTests($result, $test));
} else {
$testName = PHPUnit_Util_Test::describe($test, FALSE);
$tests[] = array('name' => $testName[1], 'object' => $test, 'result' => PHPUnit_Util_Test::lookupResult($test, $result));
}
}
return array($testSuite->getName() => $tests);
}
示例14: startTest
/**
* A test started.
*
* @param PHPUnit_Framework_Test $test
*/
public function startTest(PHPUnit_Framework_Test $test)
{
$this->current_suite()->tests[$test->getName()] = (object) array('description' => PHPUnit_Util_Test::describe($test), 'exceptions' => array(), 'assertions' => 0, 'success' => false);
$this->test =& $this->current_suite()->tests[$test->getName()];
}
示例15: endTest
/**
* A test ended.
*
* @param \PHPUnit_Framework_Test $test
* @param float $time
*
* @return void
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
if ($test instanceof \PHPUnit_Framework_TestCase) {
$assertionCount = $test->getNumAssertions();
$this->numAssertions += $assertionCount;
if ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE) {
$status = 'failures';
} elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR) {
$status = 'errors';
} elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE) {
$status = 'incompletes';
} elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED) {
$status = 'skips';
} elseif ($test->getStatus() == \PHPUnit_Runner_BaseTestRunner::STATUS_RISKY) {
$status = 'risky';
} else {
$status = 'tests';
}
if (count($this->suites) - $this->endedSuites > 1) {
$suiteName = end($this->suites);
$this->stats[$suiteName][$status]++;
$this->stats[$suiteName]['assertions'] += $assertionCount;
}
// updates also top test suite
$suiteName = reset($this->suites);
$this->stats[$suiteName][$status]++;
$this->stats[$suiteName]['assertions'] += $assertionCount;
}
if (method_exists($test, 'hasOutput') && $test->hasOutput()) {
$output = $test->getActualOutput();
} else {
$output = '';
}
$testName = $test->getName();
$context = array('testName' => $testName, 'testDescriptionArr' => \PHPUnit_Util_Test::describe($test, false), 'testDescriptionStr' => $test->toString(), 'operation' => __FUNCTION__, 'output' => $output);
if (isset($assertionCount)) {
$context['assertionCount'] = $assertionCount;
}
$this->logger->info(sprintf("Test '%s' ended.", $testName), $context);
}