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:
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user