fix(tests): tolerate a missing .env in the environment-writing pilot tests

CI checkouts have no .env, so the backup-and-restore pattern in the
installation and set-domain tests fatally failed on the first read. The
tests now seed .env from .env.example when absent, the way an installer
would, and remove it again afterwards. Developer machines are unaffected.
This commit is contained in:
Darko Gjorgjijoski
2026-08-22 14:58:34 +02:00
parent 589138f367
commit f308ed9181
3 changed files with 33 additions and 3 deletions
@@ -11,11 +11,21 @@ use function Pest\Laravel\postJson;
beforeEach(function () {
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
// CI has no .env; seed one the way an installer would so the
// env-writing paths under test have a real file to work against.
$this->envExisted = file_exists(base_path('.env'));
if (! $this->envExisted) {
copy(base_path('.env.example'), base_path('.env'));
}
$this->envBackup = file_get_contents(base_path('.env'));
});
afterEach(function () {
file_put_contents(base_path('.env'), $this->envBackup);
if ($this->envExisted) {
file_put_contents(base_path('.env'), $this->envBackup);
} else {
@unlink(base_path('.env'));
}
});
it('returns connection defaults per driver', function () {