1 | <?php |
||
23 | class Manager implements EventEmitterInterface |
||
24 | { |
||
25 | use EventEmitterTrait; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $binaries; |
||
31 | |||
32 | /** |
||
33 | * @var BinaryResolverInterface |
||
34 | */ |
||
35 | protected $resolver; |
||
36 | |||
37 | /** |
||
38 | * @var SeleniumProcessInterface |
||
39 | */ |
||
40 | protected $process; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $installPath = ''; |
||
46 | |||
47 | /** |
||
48 | * @param BinaryResolverInterface $resolver |
||
49 | * @param SeleniumProcessInterface $process |
||
50 | */ |
||
51 | public function __construct(BinaryResolverInterface $resolver = null, SeleniumProcessInterface $process = null) { |
||
62 | |||
63 | /** |
||
64 | * Add a binary to the collection of managed binaries. |
||
65 | * |
||
66 | * @param BinaryInterface $binary |
||
67 | */ |
||
68 | public function addBinary(BinaryInterface $binary) |
||
72 | |||
73 | /** |
||
74 | * Remove a binary from the collection of managed binaries. |
||
75 | * |
||
76 | * @param string $binaryName |
||
77 | */ |
||
78 | public function removeBinary($binaryName) |
||
84 | |||
85 | /** |
||
86 | * Return the BinaryResolver used to resolve binary files. |
||
87 | * |
||
88 | * @return BinaryResolver|BinaryResolverInterface |
||
89 | */ |
||
90 | public function getBinaryResolver() |
||
98 | |||
99 | /** |
||
100 | * Set the BinaryResolver used to resolve binary files. |
||
101 | * |
||
102 | * @param BinaryResolverInterface $resolver |
||
103 | */ |
||
104 | public function setBinaryResolver(BinaryResolverInterface $resolver) |
||
109 | |||
110 | /** |
||
111 | * Return the SeleniumProcessInterface that will execute the |
||
112 | * selenium server command. |
||
113 | * |
||
114 | * @return SeleniumProcess|SeleniumProcessInterface |
||
115 | */ |
||
116 | public function getSeleniumProcess() |
||
124 | |||
125 | /** |
||
126 | * Return all managed binaries. |
||
127 | * |
||
128 | * @param callable $predicate |
||
129 | * @return array |
||
130 | */ |
||
131 | public function getBinaries(callable $predicate = null) |
||
139 | |||
140 | /** |
||
141 | * Return all binaries that are considered drivers. |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | public function getDrivers() |
||
151 | |||
152 | /** |
||
153 | * Pending binaries are binaries that are supported but have not been installed. |
||
154 | * |
||
155 | * @return array |
||
156 | */ |
||
157 | public function getPendingBinaries() |
||
165 | |||
166 | /** |
||
167 | * Fetch and save binaries. |
||
168 | * |
||
169 | * @return bool |
||
170 | */ |
||
171 | public function update($binaryName = '') |
||
182 | |||
183 | /** |
||
184 | * Update a single binary. |
||
185 | * |
||
186 | * @param $binaryName |
||
187 | * @return void |
||
188 | */ |
||
189 | public function updateSingle($binaryName) |
||
198 | |||
199 | /** |
||
200 | * Start the Selenium server. |
||
201 | * |
||
202 | * @param bool $background |
||
203 | * @param int $port |
||
204 | * @param array $args |
||
205 | * @return SeleniumProcessInterface |
||
206 | */ |
||
207 | public function start($background = false, $port = 4444, array $args = []) |
||
225 | |||
226 | /** |
||
227 | * Start Selenium in the foreground. |
||
228 | * |
||
229 | * @param int $port |
||
230 | * @return SeleniumProcessInterface |
||
231 | */ |
||
232 | public function startInForeground($port = 4444, array $args = []) |
||
236 | |||
237 | /** |
||
238 | * Start Selenium in a background process. |
||
239 | * |
||
240 | * @param int $port |
||
241 | * @return SeleniumProcessInterface |
||
242 | */ |
||
243 | public function startInBackground($port = 4444, array $args = []) |
||
247 | |||
248 | /** |
||
249 | * Remove all binaries from the install path. |
||
250 | * |
||
251 | * @return void |
||
252 | */ |
||
253 | public function clean() |
||
260 | |||
261 | /** |
||
262 | * Get the installation path of binaries. |
||
263 | * |
||
264 | * @return string |
||
265 | */ |
||
266 | public function getInstallPath() |
||
274 | |||
275 | /** |
||
276 | * Set the installation path for binaries. |
||
277 | * |
||
278 | * @param string $path |
||
279 | */ |
||
280 | public function setInstallPath($path) |
||
284 | |||
285 | /** |
||
286 | * Assert that the selenium server can start. |
||
287 | * |
||
288 | * @param SeleniumStandalone $selenium |
||
289 | * @throws \RuntimeException |
||
290 | * @return void |
||
291 | */ |
||
292 | protected function assertStartConditions(SeleniumStandalone $selenium) |
||
302 | |||
303 | /** |
||
304 | * Register selenium binary and drivers with the process. |
||
305 | * |
||
306 | * @param SeleniumProcessInterface $process |
||
307 | * @param SeleniumStandalone $selenium |
||
308 | * @return void |
||
309 | */ |
||
310 | protected function registerBinaries(SeleniumProcessInterface $process, SeleniumStandalone $selenium) |
||
318 | } |
||
319 |