]> BookStack Code Mirror - bookstack/blobdiff - tests/ThemeTest.php
Editors: Properly aligned edit area border radius
[bookstack] / tests / ThemeTest.php
index 08c99d297724e249402bb15bb9ad98372b89dd34..53361e35194dad7b8fdec639373cc1a673bdfdd4 100644 (file)
@@ -8,6 +8,7 @@ use BookStack\Activity\Models\Webhook;
 use BookStack\Entities\Models\Book;
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Tools\PageContent;
+use BookStack\Exceptions\ThemeException;
 use BookStack\Facades\Theme;
 use BookStack\Theming\ThemeEvents;
 use BookStack\Users\Models\User;
@@ -51,6 +52,19 @@ class ThemeTest extends TestCase
         });
     }
 
+    public function test_theme_functions_loads_errors_are_caught_and_logged()
+    {
+        $this->usingThemeFolder(function ($themeFolder) {
+            $functionsFile = theme_path('functions.php');
+            file_put_contents($functionsFile, "<?php\n\\BookStack\\Biscuits::eat();");
+
+            $this->expectException(ThemeException::class);
+            $this->expectExceptionMessageMatches('/Failed loading theme functions file at ".*?" with error: Class "BookStack\\\\Biscuits" not found/');
+
+            $this->runWithEnv('APP_THEME', $themeFolder, fn() => null);
+        });
+    }
+
     public function test_event_commonmark_environment_configure()
     {
         $callbackCalled = false;
@@ -352,6 +366,20 @@ class ThemeTest extends TestCase
         });
     }
 
+    public function test_header_links_start_template_file_can_be_used()
+    {
+        $content = 'This is added text in the header bar';
+
+        $this->usingThemeFolder(function (string $folder) use ($content) {
+            $viewDir = theme_path('layouts/parts');
+            mkdir($viewDir, 0777, true);
+            file_put_contents($viewDir . '/header-links-start.blade.php', $content);
+            $this->setSettings(['registration-enabled' => 'true']);
+
+            $this->get('/login')->assertSee($content);
+        });
+    }
+
     protected function usingThemeFolder(callable $callback)
     {
         // Create a folder and configure a theme