create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $action = new UploadScriptAction($file, $this->faker->word()); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); static::assertTrue($result->hasFailed()); } /** * The Upload Script Action shall pass if given a valid file. * * @return void */ public function testPassed(): void { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $action = new UploadScriptAction($file, $this->faker->word()); $storageResults = $action->handle(); $result = $storageResults->toActionResult(); static::assertTrue(ActionStatus::PASSED === $result->getStatus()); } /** * The Upload Script Action shall upload the file to the configured disk. * * @return void */ public function testUploadedToDisk(): void { $fs = Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $action = new UploadScriptAction($file, $this->faker->word()); $action->handle(); static::assertCount(1, $fs->allFiles()); } /** * The Upload Video Action shall upload the file to the configured disk. * * @return void */ public function testCreatedVideo(): void { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $action = new UploadScriptAction($file, $this->faker->word()); $result = $action->handle(); $action->then($result); static::assertDatabaseCount(VideoScript::class, 1); } /** * The Upload Script Action shall attach the provided video. * * @return void */ public function testAttachesVideo(): void { Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt', $this->faker->randomDigitNotNull()); $video = Video::factory()->createOne(); $action = new UploadScriptAction($file, $this->faker->word(), $video); $result = $action->handle(); $action->then($result); static::assertTrue($video->videoscript()->exists()); } }