44
55namespace Tests \Backend \Unit \Console ;
66
7+ use App \Enums \RecordingAccess ;
8+ use App \Jobs \ProcessRecording ;
79use Illuminate \Foundation \Testing \RefreshDatabase ;
810use Illuminate \Foundation \Testing \WithFaker ;
911use Illuminate \Support \Facades \Queue ;
12+ use Illuminate \Support \Facades \Storage ;
1013use Tests \Backend \TestCase ;
1114
1215class ImportRecordingsCommandTest extends TestCase
@@ -16,19 +19,61 @@ class ImportRecordingsCommandTest extends TestCase
1619 public function test_import_recording ()
1720 {
1821 Queue::fake ();
22+ Storage::fake ('recordings-spool ' );
1923
20- config (['filesystems.disks.recordings-spool.root ' => 'tests/Backend/Fixtures/Recordings ' ]);
24+ copy (base_path ('tests/Backend/Fixtures/Recordings/invalid-recording.tar ' ), Storage::disk ('recordings-spool ' )->path ('invalid-recording.tar ' ));
25+ copy (base_path ('tests/Backend/Fixtures/Recordings/multiple.tar ' ), Storage::disk ('recordings-spool ' )->path ('multiple.tar ' ));
26+ copy (base_path ('tests/Backend/Fixtures/Recordings/notes.tar ' ), Storage::disk ('recordings-spool ' )->path ('notes.tar ' ));
2127
2228 $ this ->artisan ('import:recordings ' )->assertSuccessful ();
2329
30+ Queue::assertPushed (ProcessRecording::class, function ($ job ) {
31+ return $ job ->getFile () === 'invalid-recording.tar ' && $ job ->getAccess () === RecordingAccess::OWNER ;
32+ });
33+ Queue::assertPushed (ProcessRecording::class, function ($ job ) {
34+ return $ job ->getFile () === 'multiple.tar ' && $ job ->getAccess () === RecordingAccess::OWNER ;
35+ });
36+ Queue::assertPushed (ProcessRecording::class, function ($ job ) {
37+ return $ job ->getFile () === 'notes.tar ' && $ job ->getAccess () === RecordingAccess::OWNER ;
38+ });
39+
40+ Queue::assertCount (3 );
41+ }
42+
43+ public function test_import_public_recording ()
44+ {
45+ Queue::fake ();
46+ Storage::fake ('recordings-spool ' );
47+ Storage::disk ('recordings-spool ' )->makeDirectory ('public ' );
48+
49+ copy (base_path ('tests/Backend/Fixtures/Recordings/invalid-recording.tar ' ), Storage::disk ('recordings-spool ' )->path ('invalid-recording.tar ' ));
50+ copy (base_path ('tests/Backend/Fixtures/Recordings/multiple.tar ' ), Storage::disk ('recordings-spool ' )->path ('public/multiple.tar ' ));
51+ copy (base_path ('tests/Backend/Fixtures/Recordings/notes.tar ' ), Storage::disk ('recordings-spool ' )->path ('public/notes.tar ' ));
52+
53+ $ this ->artisan ('import:recordings ' )->assertSuccessful ();
54+
55+ Queue::assertPushed (ProcessRecording::class, function ($ job ) {
56+ return $ job ->getFile () === 'invalid-recording.tar ' && $ job ->getAccess () === RecordingAccess::OWNER ;
57+ });
58+ Queue::assertPushed (ProcessRecording::class, function ($ job ) {
59+ return $ job ->getFile () === 'public/multiple.tar ' && $ job ->getAccess () === RecordingAccess::EVERYONE ;
60+ });
61+ Queue::assertPushed (ProcessRecording::class, function ($ job ) {
62+ return $ job ->getFile () === 'public/notes.tar ' && $ job ->getAccess () === RecordingAccess::EVERYONE ;
63+ });
64+
2465 Queue::assertCount (3 );
2566 }
2667
2768 public function test_import_recording_with_hook ()
2869 {
2970 Queue::fake ();
3071
31- config (['filesystems.disks.recordings-spool.root ' => 'tests/Backend/Fixtures/Recordings ' ]);
72+ Storage::fake ('recordings-spool ' );
73+
74+ copy (base_path ('tests/Backend/Fixtures/Recordings/invalid-recording.tar ' ), Storage::disk ('recordings-spool ' )->path ('invalid-recording.tar ' ));
75+ copy (base_path ('tests/Backend/Fixtures/Recordings/multiple.tar ' ), Storage::disk ('recordings-spool ' )->path ('multiple.tar ' ));
76+ copy (base_path ('tests/Backend/Fixtures/Recordings/notes.tar ' ), Storage::disk ('recordings-spool ' )->path ('notes.tar ' ));
3277
3378 // Import hook command to write "OK" to a temp file
3479 $ tempFile = tempnam (sys_get_temp_dir (), 'recording-import-hook-test ' );
@@ -49,7 +94,11 @@ public function test_import_recording_with_failing_hook()
4994 {
5095 Queue::fake ();
5196
52- config (['filesystems.disks.recordings-spool.root ' => 'tests/Backend/Fixtures/Recordings ' ]);
97+ Storage::fake ('recordings-spool ' );
98+
99+ copy (base_path ('tests/Backend/Fixtures/Recordings/invalid-recording.tar ' ), Storage::disk ('recordings-spool ' )->path ('invalid-recording.tar ' ));
100+ copy (base_path ('tests/Backend/Fixtures/Recordings/multiple.tar ' ), Storage::disk ('recordings-spool ' )->path ('multiple.tar ' ));
101+ copy (base_path ('tests/Backend/Fixtures/Recordings/notes.tar ' ), Storage::disk ('recordings-spool ' )->path ('notes.tar ' ));
53102
54103 // Import hook command to write "OK" to a file that does not exist
55104 $ file = '/invalidPath/invalidFile ' ;
0 commit comments