Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00%
0 / 1
0.00%
0 / 23
CRAP
0.00%
0 / 119
Scenario
0.00%
0 / 1
0.00%
0 / 23
1056
0.00%
0 / 119
 __construct(\Codeception\TestCase $test)
0.00%
0 / 1
2
0.00%
0 / 4
 group($group)
0.00%
0 / 1
12
0.00%
0 / 10
 groups()
0.00%
0 / 1
2
0.00%
0 / 4
 getGroups()
0.00%
0 / 1
2
0.00%
0 / 4
 setFeature($feature)
0.00%
0 / 1
2
0.00%
0 / 3
 condition($action, $arguments)
0.00%
0 / 1
2
0.00%
0 / 4
 action($action, $arguments)
0.00%
0 / 1
2
0.00%
0 / 4
 assertion($action, $arguments)
0.00%
0 / 1
2
0.00%
0 / 4
 skip($reason = "")
0.00%
0 / 1
2
0.00%
0 / 4
 incomplete($reason = "")
0.00%
0 / 1
2
0.00%
0 / 4
 ignore()
0.00%
0 / 1
2
0.00%
0 / 4
 runStep()
0.00%
0 / 1
12
0.00%
0 / 11
 lastStep()
0.00%
0 / 1
2
0.00%
0 / 4
 addStep(\Codeception\Step $step)
0.00%
0 / 1
2
0.00%
0 / 5
 getSteps()
0.00%
0 / 1
6
0.00%
0 / 5
 getFeature()
0.00%
0 / 1
2
0.00%
0 / 3
 getHtml()
0.00%
0 / 1
12
0.00%
0 / 14
 getText()
0.00%
0 / 1
2
0.00%
0 / 7
 comment($comment)
0.00%
0 / 1
2
0.00%
0 / 3
 getCurrentStep()
0.00%
0 / 1
2
0.00%
0 / 4
 run()
0.00%
0 / 1
12
0.00%
0 / 7
 running()
0.00%
0 / 1
2
0.00%
0 / 4
 preload()
0.00%
0 / 1
2
0.00%
0 / 3
<?php
namespace Codeception;
class Scenario {
/**
* @var \Codeception\TestCase
*/
protected $test;
/**
* @var array
*/
protected $steps = array();
/**
* @var string
*/
protected $feature;
protected $currentStep = 0;
protected $running = false;
protected $preloadedSteps = array();
protected $blocker = null;
protected $groups = array();
/**
* Constructor.
*
* @param \Codeception\TestCase $test
*/
public function __construct(\Codeception\TestCase $test)
{
$this->test = $test;
}
public function group($group)
{
if (is_array($group)) {
foreach ($group as $t) {
$this->group($t);
}
} else {
$this->groups[] = $group;
}
}
public function groups()
{
$this->group(func_get_args());
}
public function getGroups()
{
return $this->groups;
}
public function setFeature($feature) {
$this->feature = $feature;
}
public function condition($action, $arguments)
{
return $this->addStep(new \Codeception\Step\Condition($action, $arguments));
}
public function action($action, $arguments)
{
return $this->addStep(new \Codeception\Step\Action($action, $arguments));
}
public function assertion($action, $arguments)
{
return $this->addStep(new \Codeception\Step\Assertion($action, $arguments));
}
public function skip($reason = "")
{
$this->blocker = new \Codeception\Step\Skip($reason, array());
}
public function incomplete($reason = "")
{
$this->blocker = new \Codeception\Step\Incomplete($reason, array());
}
protected function ignore()
{
$this->blocker = new \Codeception\Step\Ignore;
}
public function runStep()
{
if (empty($this->steps)) return;
$step = $this->lastStep();
if (!$step->executed) {
$result = $this->test->runStep($step);
$this->currentStep++;
$step->executed = true;
return $result;
}
}
/**
* @return \Codeception\Step
*/
protected function lastStep()
{
return end($this->steps);
}
protected function addStep(\Codeception\Step $step)
{
$this->steps[] = $step;
return $this->test;
}
/**
* Returns the steps of this scenario.
*
* @return array
*/
public function getSteps()
{
if (!$this->running) return $this->steps;
return $this->preloadedSteps;
}
public function getFeature() {
return $this->feature;
}
public function getHtml()
{
$text = '';
foreach($this->getSteps() as $step) {
/** @var Step $step */
if ($step->getName() !== 'Comment') {
$text .= 'I ' . $step->getHtmlAction() . '<br/>';
} else {
$text .= trim($step->getHumanizedArguments(), '"') . '<br/>';
}
}
$text = str_replace(array('((', '))'), array('...', ''), $text);
$text = "<h3>" . strtoupper('I want to ' . $this->getFeature()) . "</h3>" . $text;
return $text;
}
public function getText()
{
$text = implode("\r\n", $this->getSteps());
$text = str_replace(array('((', '))'), array('...', ''), $text);
$text = strtoupper('I want to ' . $this->getFeature()) . "\r\n\r\n" . $text;
return $text;
}
public function comment($comment) {
$this->addStep(new \Codeception\Step\Comment($comment,array()));
}
public function getCurrentStep()
{
return $this->currentStep;
}
public function run() {
if ($this->running()) return;
if ($this->blocker) return $this->blocker->run();
$this->running = true;
$this->preloadedSteps = $this->steps;
$this->steps = array();
}
public function running()
{
return $this->running;
}
public function preload() {
return !$this->running;
}
}