]> BookStack Code Mirror - bookstack/blobdiff - tests/AuditLogTest.php
Fixes for CodeStyle vol.2
[bookstack] / tests / AuditLogTest.php
index 3dc6fd7c2ecfd46b19cde94ba81f04da4a8f5d9a..bc36a184d129f3465a9e9fc855dfcabd21b98d5d 100644 (file)
@@ -1,17 +1,20 @@
-<?php namespace Tests;
+<?php
+
+namespace Tests;
 
 use BookStack\Actions\Activity;
 use BookStack\Actions\ActivityService;
 use BookStack\Actions\ActivityType;
 use BookStack\Auth\UserRepo;
-use BookStack\Entities\Tools\TrashCan;
+use BookStack\Entities\Models\Chapter;
 use BookStack\Entities\Models\Page;
 use BookStack\Entities\Repos\PageRepo;
+use BookStack\Entities\Tools\TrashCan;
 use Carbon\Carbon;
 
 class AuditLogTest extends TestCase
 {
-    /** @var ActivityService  */
+    /** @var ActivityService */
     protected $activityService;
 
     public function setUp(): void
@@ -55,7 +58,7 @@ class AuditLogTest extends TestCase
 
     public function test_shows_name_for_deleted_items()
     {
-        $this->actingAs( $this->getAdmin());
+        $this->actingAs($this->getAdmin());
         $page = Page::query()->first();
         $pageName = $page->name;
         $this->activityService->addForEntity($page, ActivityType::PAGE_CREATE);
@@ -117,4 +120,24 @@ class AuditLogTest extends TestCase
         $resp->assertDontSeeText($page->name);
     }
 
-}
\ No newline at end of file
+    public function test_user_filter()
+    {
+        $admin = $this->getAdmin();
+        $editor = $this->getEditor();
+        $this->actingAs($admin);
+        $page = Page::query()->first();
+        $this->activityService->addForEntity($page, ActivityType::PAGE_CREATE);
+
+        $this->actingAs($editor);
+        $chapter = Chapter::query()->first();
+        $this->activityService->addForEntity($chapter, ActivityType::CHAPTER_UPDATE);
+
+        $resp = $this->actingAs($admin)->get('settings/audit?user=' . $admin->id);
+        $resp->assertSeeText($page->name);
+        $resp->assertDontSeeText($chapter->name);
+
+        $resp = $this->actingAs($admin)->get('settings/audit?user=' . $editor->id);
+        $resp->assertSeeText($chapter->name);
+        $resp->assertDontSeeText($page->name);
+    }
+}