• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / dusk-updater / 13355156842

16 Feb 2025 12:49PM UTC coverage: 59.794% (+14.2%) from 45.604%
13355156842

push

github

crynobone
Merge branch '2.x' into 3.x

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

36 of 40 new or added lines in 5 files covered. (90.0%)

1 existing line in 1 file now uncovered.

58 of 97 relevant lines covered (59.79%)

1.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/src/UpdateCommand.php
1
<?php
2

3
namespace Orchestra\DuskUpdater;
4

5
use Orchestra\DuskUpdaterApi\ChromeVersionFinder;
6
use Orchestra\DuskUpdaterApi\OperatingSystem;
7
use RuntimeException;
8
use Symfony\Component\Console\Attribute\AsCommand;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputInterface;
11
use Symfony\Component\Console\Input\InputOption;
12
use Symfony\Component\Console\Output\OutputInterface;
13

14
/**
15
 * @copyright Originally created by Jonas Staudenmeir: https://github.com/staudenmeir/dusk-updater
16
 */
17
#[AsCommand(name: 'update', description: 'Install the ChromeDriver binary')]
18
class UpdateCommand extends Command
19
{
20
    /** {@inheritDoc */
21
    #[\Override]
22
    protected function configure(): void
23
    {
24
        $this->addArgument('version', InputArgument::OPTIONAL)
3✔
25
            ->addOption('all', null, InputOption::VALUE_NONE, 'Install a ChromeDriver binary for every OS');
3✔
26

27
        parent::configure();
3✔
28
    }
29

30
    /** {@inheritDoc */
31
    #[\Override]
32
    protected function execute(InputInterface $input, OutputInterface $output): int
33
    {
34
        if (\is_null($this->directory)) {
3✔
NEW
35
            throw new RuntimeException('Unable to update ChromeDriver without --install-dir');
×
36
        }
37

38
        $finder = new ChromeVersionFinder;
3✔
39

40
        $version = $finder->findVersionUrl($input->getArgument('version'));
3✔
41
        $all = $input->getOption('all');
3✔
42
        $currentOS = OperatingSystem::id();
3✔
43

44
        foreach (OperatingSystem::all() as $operatingSystem) {
3✔
45
            if ($all || ($operatingSystem === $currentOS)) {
3✔
46
                $url = $finder->resolveChromeDriverDownloadUrl($version, $operatingSystem);
3✔
47
                $archive = (new Actions\DownloadChromeDriver($this->directory, $version))->handle($url);
3✔
48
                $binary = (new Actions\PublishChromeDriver($this->directory, $operatingSystem))->handle($archive);
2✔
49
            }
50
        }
51

52
        $output->writeln(\sprintf(
2✔
53
            '<info>ChromeDriver %s successfully installed for version %s.</info>', $all ? 'binaries' : 'binary', $version
2✔
54
        ));
2✔
55

56
        return self::SUCCESS;
2✔
57
    }
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc