handle(); $response = $this->get(route('dump.latest.document.show')); $response->assertForbidden(); } /** * If no dumps exist, the user shall receive a not found error. * * @return void */ public function testNotFoundIfNoDocumentDumps(): void { Storage::fake('local'); Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Config::set(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG_QUALIFIED, true); $response = $this->get(route('dump.latest.document.show')); $response->assertNotFound(); } /** * If no document dumps exist, the user shall receive a not found error. * * @return void */ public function testNotFoundIfWikiDumpsExist(): void { Storage::fake('local'); Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Config::set(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG_QUALIFIED, true); Collection::times($this->faker->randomDigitNotNull(), function () { $action = new DumpWikiAction(); $action->handle(); }); $response = $this->get(route('dump.latest.document.show')); $response->assertNotFound(); } /** * If document dumps exist, the latest document dump is downloaded from storage through the response. * * @return void */ public function testLatestDocumentDumpDownloaded(): void { Storage::fake('local'); $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Config::set(FlagConstants::ALLOW_DUMP_DOWNLOADING_FLAG_QUALIFIED, true); Collection::times($this->faker->randomDigitNotNull(), function () { $action = new DumpWikiAction(); $action->handle(); }); Collection::times($this->faker->randomDigitNotNull(), function () { $action = new DumpDocumentAction(); $action->handle(); }); $path = Str::of(DumpDocumentAction::FILENAME_PREFIX) ->append($this->faker->word()) ->append('.sql') ->__toString(); $file = File::fake()->create($path); $fsFile = $fs->putFileAs('', $file, $path); $dump = Dump::factory()->createOne([ Dump::ATTRIBUTE_PATH => $fsFile, ]); $response = $this->get(route('dump.latest.document.show')); $response->assertDownload($dump->path); } }