createOne(); $response = $this->get(route('videoscript.show', ['videoscript' => $script])); $response->assertForbidden(); } /** * If the script is soft-deleted, the user shall receive a forbidden exception. * * @return void */ public function testSoftDeleteScriptDownloadingForbidden(): void { Config::set(FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG_QUALIFIED, false); $script = VideoScript::factory()->createOne(); $script->delete(); $response = $this->get(route('videoscript.show', ['videoscript' => $script])); $response->assertForbidden(); } /** * If script downloading is enabled, the script is downloaded from storage through the response. * * @return void */ public function testDownloadedThroughResponse(): void { Config::set(FlagConstants::ALLOW_SCRIPT_DOWNLOADING_FLAG_QUALIFIED, true); $fs = Storage::fake(Config::get(VideoConstants::SCRIPT_DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.txt'); $fsFile = $fs->putFile('', $file); $script = VideoScript::factory()->createOne([ VideoScript::ATTRIBUTE_PATH => $fsFile, ]); $response = $this->get(route('videoscript.show', ['videoscript' => $script])); static::assertInstanceOf(StreamedResponse::class, $response->baseResponse); } }