Skip to content

Commit

Permalink
LOPS-2047: Environment Variables to Terminus Functional Tests (#2538)
Browse files Browse the repository at this point in the history
* Pass env vars to functional tests

* Adjust env var parsing

* respect TERMINUS_* vars in testing environment (#2541)

---------

Co-authored-by: Tom Stovall <[email protected]>
  • Loading branch information
mitchellmarkoff and stovak authored Feb 15, 2024
1 parent ba6c676 commit 5a38020
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
24 changes: 12 additions & 12 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./tests/config/bootstrap.php"
colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="./tests/config/bootstrap.php" colors="true">
<testsuites>
<testsuite name="functional">
<directory suffix="Test.php">tests/Functional/</directory>
</testsuite>
</testsuites>
<coverage
processUncoveredFiles="true"
cacheDirectory="reports">
<coverage processUncoveredFiles="true" cacheDirectory="reports">
<include>
<directory suffix="Command.php">src/Commands</directory>
</include>
Expand All @@ -19,10 +14,15 @@
<testdoxXml outputFile="reports/logfile.xml"/>
</logging>
<php>
<server name="TERMINUS_TOKEN" value="${TERMINUS_TOKEN}" />
<server name="TERMINUS_SITE" value="${TERMINUS_SITE}" />
<server name="TERMINUS_SITE_WP" value="${TERMINUS_SITE}" />
<server name="TERMINUS_SITE_WP_NETWORK" value="${TERMINUS_SITE}" />
<server name="TERMINUS_ORG" value="${TERMINUS_ORG}" />
<server name="TERMINUS_TOKEN" value="${TERMINUS_TOKEN}" />
<server name="TERMINUS_SITE" value="${TERMINUS_SITE}" />
<server name="TERMINUS_SITE_WP" value="${TERMINUS_SITE}" />
<server name="TERMINUS_SITE_WP_NETWORK" value="${TERMINUS_SITE}" />
<server name="TERMINUS_ORG" value="${TERMINUS_ORG}" />
<server name="TERMINUS_HOST" value="${TERMINUS_HOST}" />
<server name="TERMINUS_PORT" value="${TERMINUS_PORT}" />
<server name="PANTHEON_CERT" value="${PANTHEON_CERT}" />
<server name="TERMINUS_VERIFY_HOST_CERT" value="${TERMINUS_VERIFY_HOST_CERT}" />
<server name="TERMINUS_CACHE_DIR" value="${TERMINUS_CACHE_DIR}" />
</php>
</phpunit>
18 changes: 16 additions & 2 deletions tests/Functional/TerminusTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ protected static function callTerminus(
string $command,
?string $pipeInput = null
): array {
$procCommand = sprintf('%s %s', 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 @@ -211,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 5a38020

Please sign in to comment.