mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-04 06:11:05 +00:00
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:
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user