Default templates: Fixed syntax for php8.0, added test

Null accessor is akward in php8.0 and throws warnings, so removed.
Added test to check template assingment handling on page delete.
This commit is contained in:
Dan Brown
2023-12-12 15:59:12 +00:00
parent 2f3806244c
commit 3af07addf6
2 changed files with 16 additions and 1 deletions

View 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>

View 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();