Skip to content

Commit f60a7c4

Browse files
committed
Use legacy Firefox for legacy php-webdriver
1 parent 99acd26 commit f60a7c4

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

docs/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
1919
to avoid memory exhaused errors.
2020
- Updated project dependencies to current [moodle-local_moodlecheck](https://github.com/moodlehq/moodle-local_moodlecheck) and [moodle-local_ci](https://github.com/moodlehq/moodle-local_ci) versions.
2121

22+
### Added
23+
- Detect existence of legacy php-webdriver, and use a different Firefox image when it is in use
24+
2225
## [3.0.3] - 2020-10-16
2326
### Changed
2427
- Updated version of [moodle-local_codechecker](https://github.com/moodlehq/moodle-local_codechecker) to v2.9.8.

src/Command/BehatCommand.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ class BehatCommand extends AbstractMoodleCommand
3131
*
3232
* @var string
3333
*/
34-
private $seleniumFirefoxImage = 'selenium/standalone-firefox:2.53.1';
34+
private $seleniumLegacyFirefoxImage = 'selenium/standalone-firefox:2.53.1';
35+
36+
/**
37+
* Selenium standalone Firefox image.
38+
*
39+
* @var string
40+
*/
41+
private $seleniumFirefoxImage = 'selenium/standalone-firefox:3.141.59';
3542

3643
/**
3744
* Selenium standalone Chrome image.
@@ -124,7 +131,13 @@ private function startServerProcesses(InputInterface $input)
124131
}
125132

126133
// Start docker container using desired image.
127-
$image = ($input->getOption('profile') === 'chrome') ? $this->seleniumChromeImage : $this->seleniumFirefoxImage;
134+
if ($input->getOption('profile') === 'chrome') {
135+
$image = $this->seleniumChromeImage;
136+
} elseif ($this->usesLegacyPhpWebdriver()) {
137+
$image = $this->seleniumLegacyFirefoxImage;
138+
} else {
139+
$image = $this->seleniumFirefoxImage;
140+
}
128141
$cmd = sprintf('docker run -d --rm -p 127.0.0.1:4444:4444 --name=selenium --net=host --shm-size=2g -v %s:%s %s',
129142
$this->moodle->directory, $this->moodle->directory, $image);
130143
$docker = $this->execute->passThrough($cmd);
@@ -165,4 +178,12 @@ private function dumpFailures(OutputInterface $output)
165178
}
166179
}
167180
}
181+
182+
private function usesLegacyPhpWebdriver(): bool
183+
{
184+
// The `instaclick/php-webdriver` dependency requires use of a legacy version of Firefox.
185+
$composerlock = "{$this->moodle->directory}/composer.lock";
186+
187+
return strpos(file_get_contents($composerlock), 'instaclick/php-webdriver') !== false;
188+
}
168189
}

0 commit comments

Comments
 (0)