1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace BeubiQA\Application\Command; |
4
|
|
|
|
5
|
|
|
use BeubiQA\Application\Selenium\SeleniumHandler; |
6
|
|
|
use Symfony\Component\Console\Command\Command; |
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
8
|
|
|
use Symfony\Component\Console\Input\InputOption; |
9
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
10
|
|
|
|
11
|
|
View Code Duplication |
class DownloadSeleniumCommand extends Command |
12
|
|
|
{ |
13
|
|
|
/** @var SeleniumHandler */ |
14
|
|
|
protected $seleniumHandler; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @param SeleniumHandler $seleniumHandler |
18
|
|
|
*/ |
19
|
|
|
public function __construct(SeleniumHandler $seleniumHandler) |
20
|
|
|
{ |
21
|
|
|
$this->seleniumHandler = $seleniumHandler; |
22
|
|
|
parent::__construct('start'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
protected function configure() |
26
|
|
|
{ |
27
|
|
|
$this |
28
|
|
|
->setName('get') |
29
|
|
|
->addOption( |
30
|
|
|
'selenium-version', |
31
|
|
|
's', |
32
|
|
|
InputOption::VALUE_REQUIRED, |
33
|
|
|
'Set a custom selenium version', |
34
|
|
|
'2.53.0' |
35
|
|
|
) |
36
|
|
|
->addOption( |
37
|
|
|
'selenium-destination', |
38
|
|
|
'd', |
39
|
|
|
InputOption::VALUE_REQUIRED, |
40
|
|
|
'Set a custom selenium destination directory', |
41
|
|
|
'.' |
42
|
|
|
) |
43
|
|
|
->setDescription('Downloads selenium server'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param InputInterface $input |
48
|
|
|
* @param OutputInterface $output |
49
|
|
|
* |
50
|
|
|
* @throws \RuntimeException |
51
|
|
|
*/ |
52
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
53
|
|
|
{ |
54
|
|
|
$this->setDownloaderOptionsFromInput($input); |
55
|
|
|
$this->seleniumHandler->download(); |
56
|
|
|
$output->writeln(PHP_EOL, true); |
57
|
|
|
$output->writeln('Done'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
private function setDownloaderOptionsFromInput(InputInterface $input) |
61
|
|
|
{ |
62
|
|
|
$downloaderOptions = $this->seleniumHandler->getDownloader()->getDownloaderOptions(); |
63
|
|
|
$downloaderOptions->setSeleniumDestination($input->getOption('selenium-destination')); |
64
|
|
|
$downloaderOptions->setSeleniumVersion($input->getOption('selenium-version')); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|