Started implementation of page template

This commit is contained in:
Dan Brown
2019-07-07 13:45:46 +01:00
parent f7f7cd464c
commit 71167426bb
14 changed files with 273 additions and 125 deletions

View File

@ -0,0 +1,50 @@
<?php namespace Entity;
use BookStack\Entities\Page;
use Tests\TestCase;
class PageTemplateTest extends TestCase
{
public function test_active_templates_visible_on_page_view()
{
$page = Page::first();
$this->asEditor();
$templateView = $this->get($page->getUrl());
$templateView->assertDontSee('Page Template');
$page->template = true;
$page->save();
$templateView = $this->get($page->getUrl());
$templateView->assertSee('Page Template');
}
public function test_manage_templates_permission_required_to_change_page_template_status()
{
$page = Page::first();
$editor = $this->getEditor();
$this->actingAs($editor);
$pageUpdateData = [
'name' => $page->name,
'html' => $page->html,
'template' => 'true',
];
$this->put($page->getUrl(), $pageUpdateData);
$this->assertDatabaseHas('pages', [
'id' => $page->id,
'template' => false,
]);
$this->giveUserPermissions($editor, ['templates-manage']);
$this->put($page->getUrl(), $pageUpdateData);
$this->assertDatabaseHas('pages', [
'id' => $page->id,
'template' => true,
]);
}
}