count(3)->create(); Product::create(['name' => 'Sunrise Suite A1', 'status' => 'active']); Product::create(['name' => 'Sunset Suite A2', 'status' => 'active']); $backupPath = base_path('tests/Feature/backups_test'); // Clean backup directory if it exists if (File::isDirectory($backupPath)) { File::deleteDirectory($backupPath); } // Run backup command $this->artisan('app:export-backup', [ '--path' => $backupPath, '--tables' => 'users,products', '--pretty' => true ]) ->assertExitCode(0); // Verify backup folder created $directories = File::directories($backupPath); expect($directories)->toHaveCount(1); $backupDir = $directories[0]; // Verify files created expect(File::exists("{$backupDir}/manifest.json"))->toBeTrue(); expect(File::exists("{$backupDir}/users.json"))->toBeTrue(); expect(File::exists("{$backupDir}/products.json"))->toBeTrue(); // Verify manifest contents $manifest = json_decode(File::get("{$backupDir}/manifest.json"), true); expect($manifest['tables']['users'])->toBe(3); expect($manifest['tables']['products'])->toBe(2); expect($manifest['total_rows'])->toBe(5); // Verify products contents $productsJson = json_decode(File::get("{$backupDir}/products.json"), true); expect($productsJson)->toHaveCount(2); expect($productsJson[0]['name'])->toBe('Sunrise Suite A1'); expect($productsJson[1]['name'])->toBe('Sunset Suite A2'); // Clean up backup directory File::deleteDirectory($backupPath); });