group('isolated'); beforeEach(function () { Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]); $this->envBackup = file_get_contents(base_path('.env')); }); afterEach(function () { file_put_contents(base_path('.env'), $this->envBackup); }); it('refuses a database that already contains data, without touching the environment file', function () { $path = storage_path('framework/testing/pilot-nonempty.sqlite'); @mkdir(dirname($path), 0775, true); @unlink($path); $db = new SQLite3($path); $db->exec('CREATE TABLE users (id INTEGER PRIMARY KEY)'); $db->close(); $response = postJson('/api/v1/installation/database/config', [ 'app_url' => 'http://pilot.test', 'database_connection' => 'sqlite', 'database_name' => $path, ])->assertOk()->json(); expect($response['error'])->toBe('database_should_be_empty'); expect(file_get_contents(base_path('.env')))->toBe($this->envBackup); @unlink($path); });