Skip to content

Commit

Permalink
Default templates: Fixed syntax for php8.0, added test
Browse files Browse the repository at this point in the history
Null accessor is akward in php8.0 and throws warnings, so removed.
Added test to check template assingment handling on page delete.
  • Loading branch information
ssddanbrown committed Dec 12, 2023
1 parent 2f38062 commit 3af07ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion resources/views/books/parts/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
15 changes: 15 additions & 0 deletions tests/Entity/BookDefaultTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,21 @@ public function test_creating_book_page_does_not_use_template_if_not_visible()
$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();
Expand Down

0 comments on commit 3af07ad

Please sign in to comment.