Skip to content

Commit

Permalink
adding env vars to running terminus functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Feb 7, 2024
1 parent 1228d27 commit a089582
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Request/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,10 @@ public function request($path, array $options = []): RequestOperationResult
if (isset($options['headers'])) {
$headers = array_merge($headers, $options['headers']);
}

$ttsc = getenv('TERMINUS_TESTING_STATUS');
if (intval($ttsc) > 0) {
$headers['X-Testing-Status'] = $ttsc;
}
if (strpos($path ?? '', '://') === false) {
$uri = "{$this->getBaseURI()}/api/$path";
if ($part !== 'machine-token') {
Expand Down
15 changes: 11 additions & 4 deletions tests/Functional/TerminusTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ protected function setUp(): void
*/
protected static function callTerminus(
string $command,
?string $pipeInput = null
?string $pipeInput = null,
$envVars = []
): array {
$procCommand = sprintf('%s %s', TERMINUS_BIN_FILE, $command);
if (null !== $pipeInput) {
Expand All @@ -50,7 +51,8 @@ protected static function callTerminus(
2 => ['pipe', 'w'],
],
$pipes,
dirname(__DIR__, 2)
dirname(__DIR__, 2),
$envVars,
);

if (!is_resource($process)) {
Expand Down Expand Up @@ -85,7 +87,8 @@ protected static function callTerminus(
protected function terminus(
string $command,
array $suffixParts = [],
bool $assertExitCode = true
bool $assertExitCode = true,
$envVars = []
): ?string {
if (count($suffixParts) > 0) {
$command = sprintf(
Expand All @@ -97,7 +100,11 @@ protected function terminus(
$command = sprintf('%s --yes', $command);
}

[$output, $exitCode, $error] = static::callTerminus($command);
[$output, $exitCode, $error] = static::callTerminus(
$command,
null,
$envVars
);
if (true === $assertExitCode) {
$this->assertEquals(0, $exitCode, $error);
}
Expand Down

0 comments on commit a089582

Please sign in to comment.