From 4dc75bad05558385832c6cca2133b569c3dccc79 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Fri, 11 Oct 2024 13:33:07 +0100 Subject: [PATCH] Settings: Added test to cover setting category by view --- app/Settings/SettingController.php | 2 +- tests/ThemeTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/Settings/SettingController.php b/app/Settings/SettingController.php index 447bb205b..1c5f13bc6 100644 --- a/app/Settings/SettingController.php +++ b/app/Settings/SettingController.php @@ -58,7 +58,7 @@ class SettingController extends Controller protected function ensureCategoryExists(string $category): void { if (!view()->exists('settings.categories.' . $category)) { - abort(404, 'Category not found'); + abort(404); } } } diff --git a/tests/ThemeTest.php b/tests/ThemeTest.php index 8e12b88d8..837b94eee 100644 --- a/tests/ThemeTest.php +++ b/tests/ThemeTest.php @@ -451,6 +451,19 @@ END; }); } + public function test_custom_settings_category_page_can_be_added_via_view_file() + { + $content = 'My SuperCustomSettings'; + + $this->usingThemeFolder(function (string $folder) use ($content) { + $viewDir = theme_path('settings/categories'); + mkdir($viewDir, 0777, true); + file_put_contents($viewDir . '/beans.blade.php', $content); + + $this->asAdmin()->get('/settings/beans')->assertSee($content); + }); + } + protected function usingThemeFolder(callable $callback) { // Create a folder and configure a theme