]> BookStack Code Mirror - bookstack/commitdiff
Default templates: Fixed syntax for php8.0, added test 4721/head
authorDan Brown <redacted>
Tue, 12 Dec 2023 15:59:12 +0000 (15:59 +0000)
committerDan Brown <redacted>
Tue, 12 Dec 2023 15:59:12 +0000 (15:59 +0000)
Null accessor is akward in php8.0 and throws warnings, so removed.
Added test to check template assingment handling on page delete.

resources/views/books/parts/form.blade.php
tests/Entity/BookDefaultTemplateTest.php

index 973bae987015346b0a0bbef59547749bf7f01e18..e22be619d66dd107eb54fd6b529ce292e1fb1af7 100644 (file)
@@ -49,7 +49,7 @@
                 @include('form.page-picker', [
                     'name' => 'default_template_id',
                     'placeholder' => trans('entities.books_default_template_select'),
-                    'value' => $book?->default_template_id ?? null,
+                    'value' => $book->default_template_id ?? null,
                 ])
             </div>
         </div>
index f23ba4a8e2d1c39f46cfb9b23056b970cda1b2ad..d4cd5b2c3a90f4a6e0d9490e78058cb0e4dd60c7 100644 (file)
@@ -159,6 +159,21 @@ class BookDefaultTemplateTest extends TestCase
         $this->assertEquals('', $latestPage->markdown);
     }
 
+    public function test_template_page_delete_removes_book_template_usage()
+    {
+        $templatePage = $this->entities->templatePage();
+        $book = $this->bookUsingDefaultTemplate($templatePage);
+
+        $book->refresh();
+        $this->assertEquals($templatePage->id, $book->default_template_id);
+
+        $this->asEditor()->delete($templatePage->getUrl());
+        $this->asAdmin()->post('/settings/recycle-bin/empty');
+
+        $book->refresh();
+        $this->assertEquals(null, $book->default_template_id);
+    }
+
     protected function bookUsingDefaultTemplate(Page $page): Book
     {
         $book = $this->entities->book();
Morty Proxy This is a proxified and sanitized view of the page, visit original site.