Skip to content

Commit

Permalink
Issue #625: Tugboat urls support query parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdavidburns committed Aug 30, 2024
1 parent b069b0f commit ca4d38f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/TestTugboat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
echo " - foo" >> .tugboat/config.drainpipe-override.yml
echo " urls:" >> .tugboat/config.drainpipe-override.yml
echo " - /" >> .tugboat/config.drainpipe-override.yml
echo " - /?foo=bar" >> .tugboat/config.drainpipe-override.yml
echo " screenshot:" >> .tugboat/config.drainpipe-override.yml
echo " timeout: 45" >> .tugboat/config.drainpipe-override.yml
echo " visualdiff:" >> .tugboat/config.drainpipe-override.yml
Expand Down
1 change: 1 addition & 0 deletions .tugboat/config.drainpipe-override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ php:
- foo
urls:
- /
- /?foo=bar
screenshot:
timeout: 45
visualdiff:
Expand Down
1 change: 1 addition & 0 deletions .tugboat/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:
- foo
urls:
- /
- /?foo=bar
screenshot:
timeout: 45
visualdiff:
Expand Down
29 changes: 23 additions & 6 deletions src/ScaffoldInstallerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,15 +410,32 @@ private function installTugboat(string $scaffoldPath): void {
$tugboatConfigOverride['php'] = array_filter($tugboatConfigOverride['php'],
function($key) {
return in_array($key,
['aliases', 'urls', 'visualdiff', 'screenshot']);
},
ARRAY_FILTER_USE_KEY);
['aliases', 'urls', 'visualdiff', 'screenshot']
);
}, ARRAY_FILTER_USE_KEY);

// Prepare YAML data with custom handling for URLs.
$yamlData = [];
foreach ($tugboatConfigOverride['php'] as $key => $value) {
if ($key === 'urls' && is_array($value)) {
// Ensure URLs are added without encoding.
$yamlData[$key] = $value;
} else {
$yamlData[$key] = $value;
}
}

// Convert the array to a YAML string.
$yamlString = Yaml::dump($yamlData, 2, 2);

// Indent the YAML string for formatting.
$overrideOutput = [];
foreach (explode(PHP_EOL,
Yaml::dump($tugboatConfigOverride['php'], 2, 2)) as $line) {
foreach (explode(PHP_EOL, $yamlString) as $line) {
$overrideOutput[] = str_repeat(' ', 4) . $line;
}
$tugboatConfig['overrides']['php'] = rtrim(implode("\n",

// Assign the formatted YAML string back to the configuration.
$tugboatConfig['overrides']['php'] = rtrim(implode("\n",
$overrideOutput));
}

Expand Down

0 comments on commit ca4d38f

Please sign in to comment.