3 namespace Tests\Commands;
5 use BookStack\Entities\Models\Page;
6 use Illuminate\Support\Facades\DB;
9 class ClearViewsCommandTest extends TestCase
11 public function test_clear_views_command()
14 $page = Page::first();
16 $this->get($page->getUrl());
18 $this->assertDatabaseHas('views', [
19 'user_id' => $this->users->editor()->id,
20 'viewable_id' => $page->id,
25 $exitCode = \Artisan::call('bookstack:clear-views');
26 DB::beginTransaction();
27 $this->assertTrue($exitCode === 0, 'Command executed successfully');
29 $this->assertDatabaseMissing('views', [
30 'user_id' => $this->users->editor()->id,