X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/75d6b56072df60dc6463ee025a4003b4c3418c5a..refs/pull/3918/head:/tests/Actions/AuditLogTest.php diff --git a/tests/Actions/AuditLogTest.php b/tests/Actions/AuditLogTest.php index 8fbf66e76..25fa2b796 100644 --- a/tests/Actions/AuditLogTest.php +++ b/tests/Actions/AuditLogTest.php @@ -6,8 +6,6 @@ use BookStack\Actions\Activity; use BookStack\Actions\ActivityLogger; use BookStack\Actions\ActivityType; use BookStack\Auth\UserRepo; -use BookStack\Entities\Models\Chapter; -use BookStack\Entities\Models\Page; use BookStack\Entities\Repos\PageRepo; use BookStack\Entities\Tools\TrashCan; use Carbon\Carbon; @@ -15,8 +13,7 @@ use Tests\TestCase; class AuditLogTest extends TestCase { - /** @var ActivityLogger */ - protected $activityService; + protected ActivityLogger $activityService; protected function setUp(): void { @@ -46,7 +43,7 @@ class AuditLogTest extends TestCase { $admin = $this->getAdmin(); $this->actingAs($admin); - $page = Page::query()->first(); + $page = $this->entities->page(); $this->activityService->add(ActivityType::PAGE_CREATE, $page); $activity = Activity::query()->orderBy('id', 'desc')->first(); @@ -54,13 +51,13 @@ class AuditLogTest extends TestCase $resp->assertSeeText($page->name); $resp->assertSeeText('page_create'); $resp->assertSeeText($activity->created_at->toDateTimeString()); - $this->withHtml($resp)->assertElementContains('.table-user-item', $admin->name); + $this->withHtml($resp)->assertElementContains('a[href*="users/' . $admin->id . '"]', $admin->name); } public function test_shows_name_for_deleted_items() { $this->actingAs($this->getAdmin()); - $page = Page::query()->first(); + $page = $this->entities->page(); $pageName = $page->name; $this->activityService->add(ActivityType::PAGE_CREATE, $page); @@ -76,7 +73,7 @@ class AuditLogTest extends TestCase { $viewer = $this->getViewer(); $this->actingAs($viewer); - $page = Page::query()->first(); + $page = $this->entities->page(); $this->activityService->add(ActivityType::PAGE_CREATE, $page); $this->actingAs($this->getAdmin()); @@ -89,7 +86,7 @@ class AuditLogTest extends TestCase public function test_filters_by_key() { $this->actingAs($this->getAdmin()); - $page = Page::query()->first(); + $page = $this->entities->page(); $this->activityService->add(ActivityType::PAGE_CREATE, $page); $resp = $this->get('settings/audit'); @@ -102,7 +99,7 @@ class AuditLogTest extends TestCase public function test_date_filters() { $this->actingAs($this->getAdmin()); - $page = Page::query()->first(); + $page = $this->entities->page(); $this->activityService->add(ActivityType::PAGE_CREATE, $page); $yesterday = (Carbon::now()->subDay()->format('Y-m-d')); @@ -126,11 +123,11 @@ class AuditLogTest extends TestCase $admin = $this->getAdmin(); $editor = $this->getEditor(); $this->actingAs($admin); - $page = Page::query()->first(); + $page = $this->entities->page(); $this->activityService->add(ActivityType::PAGE_CREATE, $page); $this->actingAs($editor); - $chapter = Chapter::query()->first(); + $chapter = $this->entities->chapter(); $this->activityService->add(ActivityType::CHAPTER_UPDATE, $chapter); $resp = $this->actingAs($admin)->get('settings/audit?user=' . $admin->id); @@ -146,8 +143,7 @@ class AuditLogTest extends TestCase { config()->set('app.proxies', '*'); $editor = $this->getEditor(); - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $this->actingAs($editor)->put($page->getUrl(), [ 'name' => 'Updated page', @@ -171,8 +167,7 @@ class AuditLogTest extends TestCase { config()->set('app.proxies', '*'); $editor = $this->getEditor(); - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $this->actingAs($editor)->put($page->getUrl(), [ 'name' => 'Updated page', @@ -198,8 +193,7 @@ class AuditLogTest extends TestCase config()->set('app.proxies', '*'); config()->set('app.env', 'demo'); $editor = $this->getEditor(); - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $this->actingAs($editor)->put($page->getUrl(), [ 'name' => 'Updated page', @@ -222,8 +216,7 @@ class AuditLogTest extends TestCase config()->set('app.proxies', '*'); config()->set('app.ip_address_precision', 2); $editor = $this->getEditor(); - /** @var Page $page */ - $page = Page::query()->first(); + $page = $this->entities->page(); $this->actingAs($editor)->put($page->getUrl(), [ 'name' => 'Updated page',