本文整理汇总了PHP中PHPUnit_Framework_Test::getScenario方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Test::getScenario方法的具体用法?PHP PHPUnit_Framework_Test::getScenario怎么用?PHP PHPUnit_Framework_Test::getScenario使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Test
的用法示例。
在下文中一共展示了PHPUnit_Framework_Test::getScenario方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: groupsForTest
public function groupsForTest(\PHPUnit_Framework_Test $test)
{
$groups = [];
if ($test instanceof ScenarioDriven) {
$groups = $test->getScenario()->getGroups();
}
if ($test instanceof Reported) {
$info = $test->getReportFields();
if (isset($info['class'])) {
$groups = array_merge($groups, \PHPUnit_Util_Test::getGroups($info['class'], $info['name']));
}
$filename = $info['file'];
} else {
$groups = array_merge($groups, \PHPUnit_Util_Test::getGroups(get_class($test), $test->getName(false)));
$filename = (new \ReflectionClass($test))->getFileName();
}
foreach ($this->testsInGroups as $group => $tests) {
foreach ($tests as $testPattern) {
if ($filename == $testPattern) {
$groups[] = $group;
}
if (strpos($filename . ':' . $test->getName(false), $testPattern) === 0) {
$groups[] = $group;
}
}
}
return array_unique($groups);
}
示例2: endTest
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
$steps = [];
$success = $this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
if ($success) {
$this->successful++;
}
if ($test instanceof ScenarioDriven) {
$steps = $test->getScenario()->getSteps();
}
$this->timeTaken += $time;
switch ($this->testStatus) {
case \PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE:
$scenarioStatus = 'scenarioFailed';
break;
case \PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED:
$scenarioStatus = 'scenarioSkipped';
break;
case \PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE:
$scenarioStatus = 'scenarioIncomplete';
break;
case \PHPUnit_Runner_BaseTestRunner::STATUS_ERROR:
$scenarioStatus = 'scenarioFailed';
break;
default:
$scenarioStatus = 'scenarioSuccess';
}
$stepsBuffer = '';
$metaStep = null;
$subStepsBuffer = '';
foreach ($steps as $step) {
/** @var $step Step **/
if ($step->getMetaStep()) {
$subStepsBuffer .= $this->renderStep($step);
$metaStep = $step->getMetaStep();
continue;
}
if ($step->getMetaStep() != $metaStep) {
$stepsBuffer .= $this->renderSubsteps($metaStep, $subStepsBuffer);
$subStepsBuffer = '';
}
$metaStep = $step->getMetaStep();
$stepsBuffer .= $this->renderStep($step);
}
if ($subStepsBuffer and $metaStep) {
$stepsBuffer .= $this->renderSubsteps($metaStep, $subStepsBuffer);
}
$scenarioTemplate = new \Text_Template($this->templatePath . 'scenario.html');
$failure = '';
$name = Descriptor::getTestSignature($test);
if (isset($this->failures[$name])) {
$failTemplate = new \Text_Template($this->templatePath . 'fail.html');
$failTemplate->setVar(['fail' => nl2br($this->failures[$name])]);
$failure = $failTemplate->render();
}
$toggle = $stepsBuffer ? '<span class="toggle">+</span>' : '';
$scenarioTemplate->setVar(['id' => ++$this->id, 'name' => ucfirst(Descriptor::getTestAsString($test)), 'scenarioStatus' => $scenarioStatus, 'steps' => $stepsBuffer, 'toggle' => $toggle, 'failure' => $failure, 'time' => round($time, 2)]);
$this->scenarios .= $scenarioTemplate->render();
}
示例3: endTest
/**
* A test ended.
*
* @param PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(PHPUnit_Framework_Test $test, $time)
{
if ($test instanceof PHPUnit_Extensions_Story_TestCase || $test instanceof PHPUnit_Extensions_Story_SeleniumTestCase) {
if ($this->testStatus == PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
$this->successful++;
$success = TRUE;
} else {
$success = FALSE;
}
$this->onTest($this->currentTestMethodPrettified, $success, $test->getScenario()->getSteps());
}
}
示例4: endTest
/**
* A test ended.
*
* @param \PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
$steps = [];
$success = $this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED;
if ($success) {
$this->successful++;
}
if ($test instanceof ScenarioDriven) {
$steps = $test->getScenario()->getSteps();
}
$this->onTest($test->toString(), $success, $steps, $time);
}
示例5: startTest
public function startTest(\PHPUnit_Framework_Test $test)
{
$this->dispatcher->dispatch(Events::TEST_START, new TestEvent($test));
if (!$test instanceof CodeceptionTestCase) {
return;
}
try {
$test->getScenario()->stopIfBlocked();
$this->startedTests[] = spl_object_hash($test);
$this->fire(Events::TEST_BEFORE, new TestEvent($test));
} catch (\PHPUnit_Framework_IncompleteTestError $e) {
$this->addIncompleteTest($test, $e, 0);
} catch (\PHPUnit_Framework_SkippedTestError $e) {
$this->addSkippedTest($test, $e, 0);
}
}
示例6: endTest
/**
* A test ended.
*
* @param \PHPUnit_Framework_Test $test
* @param float $time
*/
public function endTest(\PHPUnit_Framework_Test $test, $time)
{
$steps = array();
if ($this->testStatus == \PHPUnit_Runner_BaseTestRunner::STATUS_PASSED) {
$this->successful++;
$success = TRUE;
if ($test instanceof \Codeception\TestCase) {
$steps = $test->getScenario()->getSteps();
}
} else {
$success = FALSE;
if ($test instanceof \Codeception\TestCase) {
$steps = $test->getTrace();
}
}
$this->onTest($test->toString(), $success, $steps, $time);
}