From 9fcfc762ec9bf36b173a002fccbc702eeba410b3 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Tue, 27 Jan 2026 00:36:35 +0000 Subject: [PATCH] Theme: Added testing of registerViewToRender* functions Updated function name also. --- app/App/helpers.php | 3 +-- app/Theming/ThemeService.php | 4 ++-- tests/ThemeTest.php | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/App/helpers.php b/app/App/helpers.php index 0e357e36a..8f210ecaf 100644 --- a/app/App/helpers.php +++ b/app/App/helpers.php @@ -81,8 +81,7 @@ function setting(?string $key = null, mixed $default = null): mixed /** * Get a path to a theme resource. - * Returns null if a theme is not configured and - * therefore a full path is not available for use. + * Returns null if a theme is not configured, and therefore a full path is not available for use. */ function theme_path(string $path = ''): ?string { diff --git a/app/Theming/ThemeService.php b/app/Theming/ThemeService.php index 9587ceccb..0a6327af8 100644 --- a/app/Theming/ThemeService.php +++ b/app/Theming/ThemeService.php @@ -143,7 +143,7 @@ class ThemeService /** * Register a custom view to be rendered before the given target view is included in the template system. */ - public function registerViewRenderBefore(string $targetView, string $localView, int $priority = 50): void + public function registerViewToRenderBefore(string $targetView, string $localView, int $priority = 50): void { $this->registerAdjacentView($this->beforeViews, $targetView, $localView, $priority); } @@ -151,7 +151,7 @@ class ThemeService /** * Register a custom view to be rendered after the given target view is included in the template system. */ - public function registerViewRenderAfter(string $targetView, string $localView, int $priority = 50): void + public function registerViewToRenderAfter(string $targetView, string $localView, int $priority = 50): void { $this->registerAdjacentView($this->afterViews, $targetView, $localView, $priority); } diff --git a/tests/ThemeTest.php b/tests/ThemeTest.php index 841ff78ca..014f3a92f 100644 --- a/tests/ThemeTest.php +++ b/tests/ThemeTest.php @@ -492,6 +492,38 @@ END; }); } + public function test_register_view_to_render_before_and_after() + { + $this->usingThemeFolder(function (string $folder) { + $before = 'this-is-my-before-header-string'; + $afterA = 'this-is-my-after-header-string-a'; + $afterB = 'this-is-my-after-header-string-b'; + $afterC = 'this-is-my-after-header-string-{{ 1+51 }}'; + + $functionsContent = <<<'CONTENT' +refreshApplication(); + + $resp = $this->get('/login'); + $resp->assertSee($before); + // Ensure ordering of the multiple after views + $resp->assertSee($afterB . "\n" . $afterA . "\nthis-is-my-after-header-string-52"); + }); + } + protected function usingThemeFolder(callable $callback) { // Create a folder and configure a theme