diff --git a/tests/Feature/PilotSpec/InstallationDatabaseConfigTest.php b/tests/Feature/PilotSpec/InstallationDatabaseConfigTest.php index 78436e23..8a716b45 100644 --- a/tests/Feature/PilotSpec/InstallationDatabaseConfigTest.php +++ b/tests/Feature/PilotSpec/InstallationDatabaseConfigTest.php @@ -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 () { diff --git a/tests/Feature/PilotSpec/SetDomainTest.php b/tests/Feature/PilotSpec/SetDomainTest.php index 21d4598f..3a45bf87 100644 --- a/tests/Feature/PilotSpec/SetDomainTest.php +++ b/tests/Feature/PilotSpec/SetDomainTest.php @@ -8,11 +8,21 @@ use function Pest\Laravel\putJson; 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('requires a domain', function () { diff --git a/tests/Feature/PilotSpec/ZzDatabaseRefusalTest.php b/tests/Feature/PilotSpec/ZzDatabaseRefusalTest.php index f6608474..dec8304c 100644 --- a/tests/Feature/PilotSpec/ZzDatabaseRefusalTest.php +++ b/tests/Feature/PilotSpec/ZzDatabaseRefusalTest.php @@ -13,11 +13,21 @@ uses()->group('isolated'); 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('refuses a database that already contains data, without touching the environment file', function () {