create(fake()->word().'.txt', fake()->randomDigitNotNull()); $action = new UploadScriptAction($file, fake()->word()); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); $this->assertTrue($result->hasFailed()); }); test('passed', function () { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.txt', fake()->randomDigitNotNull()); $action = new UploadScriptAction($file, fake()->word()); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); $this->assertTrue($result->getStatus() === ActionStatus::PASSED); }); test('uploaded to disk', function () { $fs = Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.txt', fake()->randomDigitNotNull()); $action = new UploadScriptAction($file, fake()->word()); $action->handle(); $this->assertCount(1, $fs->allFiles()); }); test('created video', function () { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.txt', fake()->randomDigitNotNull()); $action = new UploadScriptAction($file, fake()->word()); $result = $action->handle(); $action->then($result); $this->assertDatabaseCount(VideoScript::class, 1); }); test('attaches video', function () { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create(fake()->word().'.txt', fake()->randomDigitNotNull()); $video = Video::factory()->createOne(); $action = new UploadScriptAction($file, fake()->word(), $video); $result = $action->handle(); $action->then($result); $this->assertTrue($video->videoscript()->exists()); });