Skip to content

Commit 9287860

Browse files
committed
Add Test
1 parent 1e2822d commit 9287860

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/Commands/CreateTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Carbon\Carbon;
44
use Illuminate\Support\Facades\Artisan;
5+
use Illuminate\Support\Facades\Storage;
56

67
it('can create a snapshot without a specific', function () {
78
Artisan::call('snapshot:create');
@@ -112,3 +113,31 @@
112113
->fileOnDiskToFailRegex('/CREATE TABLE(?: IF NOT EXISTS){0,1} "posts"/')
113114
->fileOnDiskToPassRegex('/CREATE TABLE(?: IF NOT EXISTS){0,1} "models"/');
114115
});
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

Comments
 (0)