1 | <?php |
||
15 | final class Context |
||
16 | { |
||
17 | use HasEventEmitterTrait; |
||
18 | |||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $suites; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $file; |
||
28 | |||
29 | /** |
||
30 | * @var Context |
||
31 | */ |
||
32 | private static $instance = null; |
||
33 | |||
34 | /** |
||
35 | * Private constructor |
||
36 | */ |
||
37 | private function __construct() |
||
41 | |||
42 | /** |
||
43 | * Clear the internal suite structure. |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function clear() |
||
53 | |||
54 | /** |
||
55 | * Set the file for the context. This file |
||
56 | * generally represents the current file being used |
||
57 | * to load suites. |
||
58 | * |
||
59 | * @param $path |
||
60 | * @return void |
||
61 | */ |
||
62 | public function setFile($path) |
||
66 | |||
67 | /** |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getFile() |
||
74 | |||
75 | /** |
||
76 | * @return \Peridot\Core\Suite |
||
77 | */ |
||
78 | public function getCurrentSuite() |
||
82 | |||
83 | /** |
||
84 | * Creates a suite and adds it to the current suite. The newly |
||
85 | * created suite will become the new "current" suite |
||
86 | * |
||
87 | * @param string $description |
||
88 | * @param callable $fn |
||
89 | * @param bool|null $pending |
||
90 | * @param bool $focused |
||
91 | */ |
||
92 | public function addSuite($description, callable $fn, $pending = null, $focused = false) |
||
103 | |||
104 | /** |
||
105 | * Create a test and add it to the current suite |
||
106 | * |
||
107 | * @param string $description |
||
108 | * @param callable $fn |
||
109 | * @param bool|null $pending |
||
110 | * @param bool $focused |
||
111 | */ |
||
112 | public function addTest($description, callable $fn = null, $pending = null, $focused = false) |
||
123 | |||
124 | /** |
||
125 | * Add a setup function for all tests in the |
||
126 | * current suite |
||
127 | * |
||
128 | * @param callable $fn |
||
129 | */ |
||
130 | public function addSetupFunction(callable $fn) |
||
134 | |||
135 | /** |
||
136 | * Add a tear down function for all tests in the current suite |
||
137 | * |
||
138 | * @param callable $fn |
||
139 | */ |
||
140 | public function addTearDownFunction(callable $fn) |
||
144 | |||
145 | /** |
||
146 | * Singleton access to Context |
||
147 | * |
||
148 | * @return Context |
||
149 | */ |
||
150 | public static function getInstance() |
||
158 | |||
159 | /** |
||
160 | * Create a Suite based on the state of the Context. |
||
161 | * |
||
162 | * @param string $description |
||
163 | * @param callable $fn |
||
164 | * @param bool|null $pending |
||
165 | * @param bool $focused |
||
166 | * @return Suite |
||
167 | */ |
||
168 | private function createSuite($description, callable $fn, $pending, $focused) |
||
178 | } |
||
179 |