]> BookStack Code Mirror - bookstack/blobdiff - tests/Permissions/RolesTest.php
Update verify-totp.blade.php
[bookstack] / tests / Permissions / RolesTest.php
index 5689caf7b93aa7db7fd4ace4df2dea2dec7eb2f5..c880bdd008938e9ea5ae4660ccf762b9e0add4c8 100644 (file)
@@ -19,7 +19,7 @@ class RolesTest extends TestCase
 {
     protected $user;
 
-    public function setUp(): void
+    protected function setUp(): void
     {
         parent::setUp();
         $this->user = $this->getViewer();
@@ -69,7 +69,7 @@ class RolesTest extends TestCase
 
         $resp = $this->post('/settings/roles/new', [
             'display_name' => $testRoleName,
-            'description' => $testRoleDesc,
+            'description'  => $testRoleDesc,
         ]);
         $resp->assertRedirect('/settings/roles');
 
@@ -78,7 +78,7 @@ class RolesTest extends TestCase
         $resp->assertSee($testRoleDesc);
         $this->assertDatabaseHas('roles', [
             'display_name' => $testRoleName,
-            'description' => $testRoleDesc,
+            'description'  => $testRoleDesc,
             'mfa_enforced' => false,
         ]);
 
@@ -93,13 +93,13 @@ class RolesTest extends TestCase
 
         $resp = $this->put('/settings/roles/' . $role->id, [
             'display_name' => $testRoleUpdateName,
-            'description' => $testRoleDesc,
+            'description'  => $testRoleDesc,
             'mfa_enforced' => 'true',
         ]);
         $resp->assertRedirect('/settings/roles');
         $this->assertDatabaseHas('roles', [
             'display_name' => $testRoleUpdateName,
-            'description' => $testRoleDesc,
+            'description'  => $testRoleDesc,
             'mfa_enforced' => true,
         ]);
 
@@ -173,11 +173,11 @@ class RolesTest extends TestCase
     public function test_manage_users_permission_shows_link_in_header_if_does_not_have_settings_manage_permision()
     {
         $usersLink = 'href="' . url('/settings/users') . '"';
-        $this->actingAs($this->user)->get('/')->assertDontSee($usersLink);
+        $this->actingAs($this->user)->get('/')->assertDontSee($usersLink, false);
         $this->giveUserPermissions($this->user, ['users-manage']);
-        $this->actingAs($this->user)->get('/')->assertSee($usersLink);
+        $this->actingAs($this->user)->get('/')->assertSee($usersLink, false);
         $this->giveUserPermissions($this->user, ['settings-manage', 'users-manage']);
-        $this->actingAs($this->user)->get('/')->assertDontSee($usersLink);
+        $this->actingAs($this->user)->get('/')->assertDontSee($usersLink, false);
     }
 
     public function test_user_cannot_change_email_unless_they_have_manage_users_permission()
@@ -321,7 +321,7 @@ class RolesTest extends TestCase
         ]);
 
         $this->post('/shelves', [
-            'name' => 'test shelf',
+            'name'        => 'test shelf',
             'description' => 'shelf desc',
         ])->assertRedirect('/shelves/test-shelf');
     }
@@ -402,7 +402,7 @@ class RolesTest extends TestCase
         ]);
 
         $this->post('/books', [
-            'name' => 'test book',
+            'name'        => 'test book',
             'description' => 'book desc',
         ])->assertRedirect('/books/test-book');
     }
@@ -480,7 +480,7 @@ class RolesTest extends TestCase
         ]);
 
         $this->post($ownBook->getUrl('/create-chapter'), [
-            'name' => 'test chapter',
+            'name'        => 'test chapter',
             'description' => 'chapter desc',
         ])->assertRedirect($ownBook->getUrl('/chapter/test-chapter'));
 
@@ -499,7 +499,7 @@ class RolesTest extends TestCase
         ]);
 
         $this->post($book->getUrl('/create-chapter'), [
-            'name' => 'test chapter',
+            'name'        => 'test chapter',
             'description' => 'chapter desc',
         ])->assertRedirect($book->getUrl('/chapter/test-chapter'));
     }
@@ -769,10 +769,10 @@ class RolesTest extends TestCase
         $this->giveUserPermissions($this->user, ['image-update-all']);
         /** @var Page $page */
         $page = Page::query()->first();
-        $image = factory(Image::class)->create([
+        $image = Image::factory()->create([
             'uploaded_to' => $page->id,
-            'created_by' => $this->user->id,
-            'updated_by' => $this->user->id,
+            'created_by'  => $this->user->id,
+            'updated_by'  => $this->user->id,
         ]);
 
         $this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
@@ -789,7 +789,7 @@ class RolesTest extends TestCase
         $admin = $this->getAdmin();
         /** @var Page $page */
         $page = Page::query()->first();
-        $image = factory(Image::class)->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
+        $image = Image::factory()->create(['uploaded_to' => $page->id, 'created_by' => $admin->id, 'updated_by' => $admin->id]);
 
         $this->actingAs($this->user)->json('delete', '/images/' . $image->id)->assertStatus(403);
 
@@ -825,14 +825,14 @@ class RolesTest extends TestCase
     {
         $admin = $this->getAdmin();
         // Book links
-        $book = factory(Book::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
+        $book = Book::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id]);
         $this->regenEntityPermissions($book);
         $this->actingAs($this->getViewer())->get($book->getUrl())
             ->assertDontSee('Create a new page')
             ->assertDontSee('Add a chapter');
 
         // Chapter links
-        $chapter = factory(Chapter::class)->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
+        $chapter = Chapter::factory()->create(['created_by' => $admin->id, 'updated_by' => $admin->id, 'book_id' => $book->id]);
         $this->regenEntityPermissions($chapter);
         $this->actingAs($this->getViewer())->get($chapter->getUrl())
             ->assertDontSee('Create a new page')
@@ -926,13 +926,15 @@ class RolesTest extends TestCase
 
     private function addComment(Page $page): TestResponse
     {
-        $comment = factory(Comment::class)->make();
+        $comment = Comment::factory()->make();
+
         return $this->postJson("/comment/$page->id", $comment->only('text', 'html'));
     }
 
     private function updateComment(Comment $comment): TestResponse
     {
-        $commentData = factory(Comment::class)->make();
+        $commentData = Comment::factory()->make();
+
         return $this->putJson("/comment/{$comment->id}", $commentData->only('text', 'html'));
     }