From e015d047e9db847f445f4f910650949f931f6770 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 21 Jul 2023 22:05:07 +0800 Subject: [PATCH] wip Signed-off-by: Mior Muhammad Zaki --- src/DetectCommand.php | 11 +++++++---- tests/HelpersTest.php | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 tests/HelpersTest.php diff --git a/src/DetectCommand.php b/src/DetectCommand.php index c7d3f38..21e48cf 100644 --- a/src/DetectCommand.php +++ b/src/DetectCommand.php @@ -63,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if ($autoUpdate || $io->confirm('Do you want to update ChromeDriver?')) { - $this->updateChromeDriver($output, $driverDirectory, $chromeVersions['major']); + $this->updateChromeDriver($input, $output, $driverDirectory, $chromeVersions['major']); } } @@ -73,18 +73,21 @@ protected function execute(InputInterface $input, OutputInterface $output) /** * Update ChromeDriver. */ - protected function updateChromeDriver(OutputInterface $output, string $directory, int $version): int + protected function updateChromeDriver(InputInterface $input, OutputInterface $output, string $directory, int $version): int { /** @var \Symfony\Component\Console\Application $console */ $console = $this->getApplication(); $command = $console->find('update'); - $arguments = [ + $arguments = array_merge([ 'command' => 'update', 'version' => $version, '--install-dir' => $directory, - ]; + ], array_filter([ + '--proxy' => $input->getOption('proxy'), + '--ssl-no-verify' => $input->getOption('ssl-no-verify'), + ])); return $command->run(new ArrayInput($arguments), $output); } diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php new file mode 100644 index 0000000..169f35e --- /dev/null +++ b/tests/HelpersTest.php @@ -0,0 +1,30 @@ +assertSame(chromedriver_binary_filename($given, $os), $expected); + } + + public static function binaryFileDataProvider() + { + yield ['linux', 'chromedriver', 'chromedriver-linux']; + yield ['mac-intel', 'chromedriver', 'chromedriver-mac-intel']; + yield ['mac-arm', 'chromedriver', 'chromedriver-mac-arm']; + yield ['win32', 'chromedriver.exe', 'chromedriver-win32.exe']; + + yield ['linux', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver', 'chromedriver-linux']; + yield ['mac-intel', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver', 'chromedriver-mac-intel']; + yield ['mac-arm', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver', 'chromedriver-mac-arm']; + yield ['win32', 'chromedriver-115'.DIRECTORY_SEPARATOR.'chromedriver.exe', 'chromedriver-win32.exe']; + } +}