]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/PageTemplateTest.php
Comments: Added HTML filter on load, tinymce elem filtering
[bookstack] / tests / Entity / PageTemplateTest.php
index a5594e8b8df06ececf95ae1df6d8256590738e91..6a68c3ab18ff4d80852e632cc4f036dc8ba0d075 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace Tests\Entity;
+<?php
+
+namespace Tests\Entity;
 
 use BookStack\Entities\Models\Page;
 use Tests\TestCase;
@@ -7,7 +9,7 @@ class PageTemplateTest extends TestCase
 {
     public function test_active_templates_visible_on_page_view()
     {
-        $page = Page::first();
+        $page = $this->entities->page();
 
         $this->asEditor();
         $templateView = $this->get($page->getUrl());
@@ -22,27 +24,27 @@ class PageTemplateTest extends TestCase
 
     public function test_manage_templates_permission_required_to_change_page_template_status()
     {
-        $page = Page::first();
-        $editor = $this->getEditor();
+        $page = $this->entities->page();
+        $editor = $this->users->editor();
         $this->actingAs($editor);
 
         $pageUpdateData = [
-            'name' => $page->name,
-            'html' => $page->html,
+            'name'     => $page->name,
+            'html'     => $page->html,
             'template' => 'true',
         ];
 
         $this->put($page->getUrl(), $pageUpdateData);
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
+            'id'       => $page->id,
             'template' => false,
         ]);
 
-        $this->giveUserPermissions($editor, ['templates-manage']);
+        $this->permissions->grantUserRolePermissions($editor, ['templates-manage']);
 
         $this->put($page->getUrl(), $pageUpdateData);
         $this->assertDatabaseHas('pages', [
-            'id' => $page->id,
+            'id'       => $page->id,
             'template' => true,
         ]);
     }
@@ -50,8 +52,8 @@ class PageTemplateTest extends TestCase
     public function test_templates_content_should_be_fetchable_only_if_page_marked_as_template()
     {
         $content = '<div>my_custom_template_content</div>';
-        $page = Page::first();
-        $editor = $this->getEditor();
+        $page = $this->entities->page();
+        $editor = $this->users->editor();
         $this->actingAs($editor);
 
         $templateFetch = $this->get('/templates/' . $page->id);
@@ -64,14 +66,14 @@ class PageTemplateTest extends TestCase
         $templateFetch = $this->get('/templates/' . $page->id);
         $templateFetch->assertStatus(200);
         $templateFetch->assertJson([
-            'html' => $content,
+            'html'     => $content,
             'markdown' => '',
         ]);
     }
 
     public function test_template_endpoint_returns_paginated_list_of_templates()
     {
-        $editor = $this->getEditor();
+        $editor = $this->users->editor();
         $this->actingAs($editor);
 
         $toBeTemplates = Page::query()->orderBy('name', 'asc')->take(12)->get();
@@ -86,5 +88,4 @@ class PageTemplateTest extends TestCase
         $templatesFetch->assertSee($page->name);
         $templatesFetch->assertSee('pagination');
     }
-
-}
\ No newline at end of file
+}