1 | <?php |
||
9 | class Suite extends AbstractTest |
||
10 | { |
||
11 | /** |
||
12 | * Tests belonging to this suite |
||
13 | * |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $tests = []; |
||
17 | |||
18 | /** |
||
19 | * Has the suite been halted |
||
20 | * |
||
21 | * @var bool |
||
22 | */ |
||
23 | protected $halted = false; |
||
24 | |||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | * |
||
28 | * @return bool |
||
29 | */ |
||
30 | public function isFocused() |
||
31 | { |
||
32 | if ($this->focused === true) { |
||
33 | return $this->focused; |
||
34 | } |
||
35 | |||
36 | foreach ($this->tests as $test) { |
||
37 | if ($test->isFocused()) { |
||
38 | return true; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | return false; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Add a test to the suite |
||
47 | * |
||
48 | * @param Test $test |
||
49 | */ |
||
50 | public function addTest(TestInterface $test) |
||
55 | |||
56 | /** |
||
57 | * Return collection of tests |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | public function getTests() |
||
65 | |||
66 | /** |
||
67 | * Set suite tests |
||
68 | * |
||
69 | * @param array $tests |
||
70 | */ |
||
71 | public function setTests(array $tests) |
||
75 | |||
76 | /** |
||
77 | * Execute the Suite definition. |
||
78 | * |
||
79 | * @return void |
||
80 | */ |
||
81 | public function define() |
||
86 | |||
87 | /** |
||
88 | * Run all the specs belonging to the suite |
||
89 | * |
||
90 | * @param TestResult $result |
||
91 | */ |
||
92 | public function run(TestResult $result) |
||
107 | |||
108 | /** |
||
109 | * Put the Suite in a halted state. A halted Suite will not run or will |
||
110 | * stop running if currently running. |
||
111 | * |
||
112 | * @return void |
||
113 | */ |
||
114 | public function halt() |
||
118 | |||
119 | /** |
||
120 | * Run a test and track its results. |
||
121 | * |
||
122 | * @param TestInterface $test |
||
123 | * @param TestResult $result |
||
124 | */ |
||
125 | protected function runTest(TestInterface $test, TestResult $result) |
||
134 | |||
135 | /** |
||
136 | * Get the subset of the defined tests that should actually be run. |
||
137 | * |
||
138 | * @return array |
||
139 | */ |
||
140 | protected function getTestsToRun() |
||
148 | } |
||
149 |