Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions .harness.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@
"laravel/prompts"
],
"allow_commands": [
{
"command": "new",
"reason": "the installer is named for the tool, like laravel new; renaming it would change the public API of the CLI"
},
{
"command": "self-update",
"reason": "the command is named for the tool, like composer self-update; renaming it would change the public API of the CLI"
},
{
"command": "version",
"reason": "the command is named for the tool; renaming it would change the public API of the CLI"
}
{ "command": "new", "reason": "the installer is named for the tool, like laravel new; renaming it would change the public API of the CLI" },
{ "command": "self-update", "reason": "the command is named for the tool, like composer self-update; renaming it would change the public API of the CLI" },
{ "command": "version", "reason": "the command is named for the tool; renaming it would change the public API of the CLI" }
],
"ratchet": {
"phpstan_level": 8,
"phpstan_baseline": 0,
"coverage": 36.86
"coverage": 92
}
}
20 changes: 19 additions & 1 deletion tests/Support/Sandbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ final class Sandbox
/** @var array<string, mixed> */
private array $originalServer = [];

/** @var array<string, mixed> */
private array $originalSuperEnv = [];

public function __construct()
{
$this->root = realpath(sys_get_temp_dir()).'/pollora-cli-'.bin2hex(random_bytes(6));
Expand Down Expand Up @@ -61,9 +64,16 @@ public function env(string $name, string $value): void
$this->originalServer[$name] = $_SERVER[$name] ?? null;
}

// Symfony Process only passes on the variables that $_SERVER also knows.
if (! array_key_exists($name, $this->originalSuperEnv)) {
$this->originalSuperEnv[$name] = $_ENV[$name] ?? null;
}

// Symfony Process builds the environment of a child from the variables that $_SERVER also knows,
// then lets $_ENV override them: $_ENV is empty with the php.ini of macOS (variables_order GPCS)
// and filled on Linux, where it would bring back the original PATH. Both are set.
putenv($name.'='.$value);
$_SERVER[$name] = $value;
$_ENV[$name] = $value;
}

/**
Expand Down Expand Up @@ -129,6 +139,14 @@ public function restore(): void
}
}

foreach ($this->originalSuperEnv as $name => $value) {
if ($value === null) {
unset($_ENV[$name]);
} else {
$_ENV[$name] = $value;
}
}

self::removeTree($this->root);
}

Expand Down
Loading