Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Jul 21, 2023
1 parent 468fcb9 commit e015d04
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/DetectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}

Expand All @@ -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);
}
Expand Down
30 changes: 30 additions & 0 deletions tests/HelpersTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Orchestra\DuskUpdater\Tests;

use function Orchestra\DuskUpdater\chromedriver_binary_filename;
use PHPUnit\Framework\TestCase;

class HelpersTest extends TestCase
{
/**
* @dataProvider binaryFileDataProvider
*/
public function test_it_can_resolve_correct_filename($os, $given, $expected)
{
$this->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'];
}
}

0 comments on commit e015d04

Please sign in to comment.