Skip to content

Commit

Permalink
respect TERMINUS_* vars in testing environment
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Feb 14, 2024
1 parent c4a9310 commit aafed69
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions tests/Functional/TerminusTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,21 @@ protected static function callTerminus(
string $command,
?string $pipeInput = null
): array {
$terminusHost = isset($_ENV['TERMINUS_HOST']) ? "TERMINUS_HOST=" . $_ENV['TERMINUS_HOST'] : "";
$procCommand = sprintf('%s %s %s', $terminusHost, TERMINUS_BIN_FILE, $command);
$preamble = '';
foreach (
[
'TERMINUS_HOST',
'TERMINUS_PORT',
'TERMINUS_VERIFY_HOST_CERT',
'TERMINUS_CACHE_DIR',
'PANTHEON_CERT'
] as $envVar
) {
if (false !== getenv($envVar)) {
$preamble .= sprintf('%s=%s ', $envVar, getenv($envVar));
}
}
$procCommand = sprintf('%s %s %s', $preamble, TERMINUS_BIN_FILE, $command);
if (null !== $pipeInput) {
$procCommand = sprintf('%s | %s', $pipeInput, $procCommand);
}
Expand Down Expand Up @@ -212,7 +225,7 @@ protected function assertTerminusCommandSucceedsInAttempts(
int $attempts = 3
): void {
$this->assertTerminusCommandResultEqualsInAttempts(
fn () => static::callTerminus(sprintf('%s --yes', $command))[1],
fn() => static::callTerminus(sprintf('%s --yes', $command))[1],
0,
$attempts
);
Expand Down

0 comments on commit aafed69

Please sign in to comment.