|
2 | 2 |
|
3 | 3 | use Carbon\Carbon; |
4 | 4 | use Illuminate\Support\Facades\Artisan; |
| 5 | +use Illuminate\Support\Facades\Storage; |
5 | 6 |
|
6 | 7 | it('can create a snapshot without a specific', function () { |
7 | 8 | Artisan::call('snapshot:create'); |
|
112 | 113 | ->fileOnDiskToFailRegex('/CREATE TABLE(?: IF NOT EXISTS){0,1} "posts"/') |
113 | 114 | ->fileOnDiskToPassRegex('/CREATE TABLE(?: IF NOT EXISTS){0,1} "models"/'); |
114 | 115 | }); |
| 116 | + |
| 117 | +it('passes extraOptions correctly to the command', function () { |
| 118 | + // Set up |
| 119 | + Storage::fake('snapshots'); |
| 120 | + |
| 121 | + // Mock or set the extraOptions you want to test |
| 122 | + $extraOptions = ['--compress' => true, '--exclude-tables' => 'logs']; |
| 123 | + |
| 124 | + // Execute the artisan command with extra options |
| 125 | + Artisan::call('snapshot:create', [ |
| 126 | + 'name' => 'test_snapshot', |
| 127 | + '--disk' => 'snapshots', |
| 128 | + '--extraOptions' => json_encode($extraOptions), |
| 129 | + ]); |
| 130 | + |
| 131 | + // Assertions |
| 132 | + $output = Artisan::output(); |
| 133 | + expect($output)->toContain('--compress')->toContain('true'); |
| 134 | + expect($output)->toContain('--exclude-tables')->toContain('logs'); |
| 135 | + |
| 136 | + // Verify the snapshot file was created |
| 137 | + $snapshotFileName = 'test_snapshot.sql'; |
| 138 | + Storage::disk('snapshots')->assertExists($snapshotFileName); |
| 139 | + |
| 140 | + // Optionally, check the snapshot's content or metadata |
| 141 | + $snapshotContent = Storage::disk('snapshots')->get($snapshotFileName); |
| 142 | + expect($snapshotContent)->toContain('--compress')->toContain('--exclude-tables'); |
| 143 | +}); |
0 commit comments