Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 12 |
CRAP | |
0.00% |
0 / 90 |
AbstractGuy | |
0.00% |
0 / 1 |
|
0.00% |
0 / 12 |
462 | |
0.00% |
0 / 90 |
__construct(\Codeception\Scenario $scenario) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
wantToTest($text) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
wantTo($text) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 9 |
|||
amTesting($method) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 4 |
|||
amTestingMethod($method) | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 5 |
|||
testMethod($signature) | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 14 |
|||
expectTo($prediction) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 9 |
|||
expect($prediction) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 9 |
|||
amGoingTo($argumentation) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 9 |
|||
am($role) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
lookForwardTo($role) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 7 |
|||
__call($method, $arguments) | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
<?php | |
namespace Codeception; | |
abstract class AbstractGuy | |
{ | |
public static $methods = array(); | |
/** | |
* @var \Codeception\Scenario | |
*/ | |
protected $scenario; | |
protected $running = false; | |
public function __construct(\Codeception\Scenario $scenario) | |
{ | |
$this->scenario = $scenario; | |
} | |
public function wantToTest($text) | |
{ | |
return $this->wantTo('test ' . $text); | |
} | |
public function wantTo($text) | |
{ | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
$this->scenario->setFeature(strtolower($text)); | |
return $this; | |
} | |
public function amTesting($method) | |
{ | |
return $this->testMethod($method); | |
} | |
public function amTestingMethod($method) | |
{ | |
$this->testMethod($method); | |
return $this; | |
} | |
public function testMethod($signature) | |
{ | |
$this->scenario->condition('testMethod', array($signature)); | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
if (!$this->scenario->getFeature()) { | |
$this->scenario->setFeature("test method $signature()"); | |
} else { | |
$this->scenario->setFeature($this->scenario->getFeature() . " with [[$signature]]"); | |
} | |
return $this; | |
} | |
public function expectTo($prediction) | |
{ | |
$this->scenario->comment('I expect to ' . $prediction); | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
return $this; | |
} | |
public function expect($prediction) | |
{ | |
$this->scenario->comment('I expect ' . $prediction); | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
return $this; | |
} | |
public function amGoingTo($argumentation) | |
{ | |
$this->scenario->comment('I am going to ' . $argumentation); | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
return $this; | |
} | |
public function am($role) { | |
$this->scenario->comment('As a ' . $role); | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
return $this; | |
} | |
public function lookForwardTo($role) { | |
$this->scenario->comment('So that I ' . $role); | |
if ($this->scenario->running()) { | |
$this->scenario->runStep(); | |
return $this; | |
} | |
} | |
public function __call($method, $arguments) { | |
if ($this->scenario->running()) { | |
$class = get_class($this); | |
throw new \RuntimeException("Call to undefined method $class::$method"); | |
} else { | |
$this->scenario->action($method, $arguments); | |
} | |
} | |
} |