Repository navigation
Expand file tree
/
Copy pathTestCase.php
More file actions
111 lines (92 loc) · 2.78 KB
/
Copy pathTestCase.php
File metadata and controls
111 lines (92 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
namespace Codeception;
use Codeception\Event\StepEvent;
use Codeception\Exception\ConditionalAssertionFailed;
use Symfony\Component\EventDispatcher\Event;
abstract class TestCase extends \PHPUnit_Framework_TestCase implements \PHPUnit_Framework_SelfDescribing
{
/**
* @var \Codeception\Scenario
*/
protected $scenario;
protected $trace = array();
protected $backupGlobalsBlacklist = array('app');
protected $dependencies;
protected $dispatcher;
protected function fire($event, Event $eventType)
{
foreach ($this->scenario->getGroups() as $group) {
$this->dispatcher->dispatch($event . '.' . $group, $eventType);
}
$this->dispatcher->dispatch($event, $eventType);
}
protected function handleDependencies()
{
if (empty($this->dependencies)) {
return true;
}
$passed = $this->getTestResultObject()->passed();
$testNames = array_map(
function ($testname) {
return preg_replace('~with data set (.*?)~', '', $testname);
},
array_keys($passed)
);
$testNames = array_unique($testNames);
foreach ($this->dependencies as $dependency) {
if (in_array($dependency, $testNames)) {
continue;
}
$this->getTestResultObject()->addError(
$this,
new \PHPUnit_Framework_SkippedTestError("This test depends on '$dependency' to pass."),
0
);
return false;
}
return true;
}
public function runStep(Step $step)
{
$this->trace[] = $step;
$this->fire(CodeceptionEvents::STEP_BEFORE, new StepEvent($this, $step));
try {
$result = $step->run();
} catch (ConditionalAssertionFailed $f) {
$result = $this->getTestResultObject();
$result->addFailure(clone($this), $f, $result->time());
} catch (\Exception $e) {
$this->fire(CodeceptionEvents::STEP_AFTER, new StepEvent($this, $step));
throw $e;
}
$this->fire(CodeceptionEvents::STEP_AFTER, new StepEvent($this, $step));
return $result;
}
public function getFeature()
{
return null;
}
public function getFileName()
{
return get_class($this) . '::' . $this->getName(false);
}
/**
* @return \Codeception\Scenario
*/
public function getScenario()
{
return $this->scenario;
}
public function getTrace()
{
return $this->trace;
}
public function toString()
{
return $this->getFeature();
}
public function setDependencies(array $dependencies)
{
$this->dependencies = $dependencies;
}
}