Simplify: fix fallback bug, reduce redundancy, restore step PHPDocs

- FailureShowListener: fix show_tmp_dir fallback '' -> sys_get_temp_dir()
  (bug introduced by duplication with MinkContext::showLastResponse)
- SauceLabsFactory: simplify `is_bool($x) ? $x : (bool) $x` -> `(bool) $x`
- MinkExtension::load: extract $baseUrl/$browserName locals to avoid
  evaluating the same `?? ''` expression twice per line
- EnvironmentCapabilities: store TRAVIS_JOB_NUMBER and JENKINS_HOME
  getenv() results before the switch to avoid double calls per match
- MinkContext: restore PHPDoc comments on all step methods (Example lines
  for discoverability); keep PHP attributes, no @Given/@When/@Then tags

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kamil Kokot
2026-06-12 17:50:42 +02:00
parent 47a9d45cd1
commit 2947994733
5 changed files with 210 additions and 7 deletions

View File

@@ -12,10 +12,13 @@ trait EnvironmentCapabilities
*/
private function guessEnvironmentCapabilities(): array
{
$travisJobNumber = getenv('TRAVIS_JOB_NUMBER');
$jenkinsHome = getenv('JENKINS_HOME');
switch (true) {
case (bool) getenv('TRAVIS_JOB_NUMBER'):
case (bool) $travisJobNumber:
return [
'tunnel-identifier' => getenv('TRAVIS_JOB_NUMBER'),
'tunnel-identifier' => $travisJobNumber,
'build' => getenv('TRAVIS_BUILD_NUMBER'),
'tags' => [
'Travis-CI',
@@ -23,7 +26,7 @@ trait EnvironmentCapabilities
],
];
case (bool) getenv('JENKINS_HOME'):
case (bool) $jenkinsHome:
return [
'tunnel-identifier' => getenv('JOB_NAME'),
'build' => getenv('BUILD_NUMBER'),

View File

@@ -39,7 +39,7 @@ class SauceLabsFactory extends Selenium2Factory
public function buildDriver(array $config): Definition
{
$host = 'ondemand.saucelabs.com';
if (is_bool($config['connect']) ? $config['connect'] : (bool) $config['connect']) {
if ((bool) $config['connect']) {
$host = 'localhost:4445';
}

View File

@@ -98,8 +98,10 @@ class MinkExtension implements ExtensionInterface
unset($config['sessions']);
$container->setParameter('mink.parameters', $config);
$container->setParameter('mink.base_url', is_string($config['base_url'] ?? '') ? ($config['base_url'] ?? '') : '');
$container->setParameter('mink.browser_name', is_string($config['browser_name'] ?? '') ? ($config['browser_name'] ?? '') : '');
$baseUrl = $config['base_url'] ?? '';
$container->setParameter('mink.base_url', is_string($baseUrl) ? $baseUrl : '');
$browserName = $config['browser_name'] ?? '';
$container->setParameter('mink.browser_name', is_string($browserName) ? $browserName : '');
}
public function configure(ArrayNodeDefinition $builder): void