createOne(); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertForbidden(); } /** * If the dump is soft-deleted, the user shall receive a not found exception. * * @return void */ public function testCannotDownloadSoftDeletedDump(): void { Config::set(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG_QUALIFIED, true); $dump = Dump::factory()->createOne(); $dump->delete(); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertNotFound(); } /** * If dump downloading is enabled, the dump is downloaded from storage through the response. * * @return void */ public function testDownloadedThroughResponse(): void { Config::set(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG_QUALIFIED, true); $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); $file = File::fake()->create($this->faker->word().'.sql'); $fsFile = $fs->putFile('', $file); $dump = Dump::factory()->createOne([ Dump::ATTRIBUTE_PATH => $fsFile, ]); $response = $this->get(route('dump.show', ['dump' => $dump])); $response->assertDownload($dump->path); } }