handle(); $response = get(route('dump.latest.wiki.show')); $response->assertForbidden(); }); test('video streaming permitted for bypass', function () { Storage::fake('local'); $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Feature::activate(AllowDumpDownloading::class, fake()->boolean()); Collection::times(fake()->randomDigitNotNull(), function () { $action = new DumpDocumentAction(); $action->handle(); }); Collection::times(fake()->randomDigitNotNull(), function () { $action = new DumpWikiAction(); $action->handle(); }); $path = Str::of(DumpWikiAction::FILENAME_PREFIX) ->append(fake()->word()) ->append('.sql') ->__toString(); $file = File::fake()->create($path); $fsFile = $fs->putFileAs('', $file, $path); $dump = Dump::factory()->createOne([ Dump::ATTRIBUTE_PATH => $fsFile, ]); $user = User::factory()->withPermissions(SpecialPermission::BYPASS_FEATURE_FLAGS->value)->createOne(); Sanctum::actingAs($user); $response = get(route('dump.latest.wiki.show')); $response->assertDownload($dump->path); }); test('not found if no wiki dumps', function () { Storage::fake('local'); Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Feature::activate(AllowDumpDownloading::class); $response = get(route('dump.latest.wiki.show')); $response->assertNotFound(); }); test('not found if document dumps exist', function () { Storage::fake('local'); Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Feature::activate(AllowDumpDownloading::class); Collection::times(fake()->randomDigitNotNull(), function () { $action = new DumpDocumentAction(); $action->handle(); }); $response = get(route('dump.latest.wiki.show')); $response->assertNotFound(); }); test('latest wiki dump downloaded', function () { Storage::fake('local'); $fs = Storage::fake(Config::get(DumpConstants::DISK_QUALIFIED)); Feature::activate(AllowDumpDownloading::class); Collection::times(fake()->randomDigitNotNull(), function () { $action = new DumpDocumentAction(); $action->handle(); }); Collection::times(fake()->randomDigitNotNull(), function () { $action = new DumpWikiAction(); $action->handle(); }); $path = Str::of(DumpWikiAction::FILENAME_PREFIX) ->append(fake()->word()) ->append('.sql') ->__toString(); $file = File::fake()->create($path); $fsFile = $fs->putFileAs('', $file, $path); $dump = Dump::factory()->createOne([ Dump::ATTRIBUTE_PATH => $fsFile, ]); $response = get(route('dump.latest.wiki.show')); $response->assertDownload($dump->path); });