]> BookStack Code Mirror - bookstack/blob - tests/Commands/ClearViewsCommandTest.php
Split command tests out to indavidual test files
[bookstack] / tests / Commands / ClearViewsCommandTest.php
1 <?php namespace Tests\Commands;
2
3 use BookStack\Entities\Models\Page;
4 use Tests\TestCase;
5
6 class ClearViewsCommandTest extends TestCase
7 {
8
9     public function test_clear_views_command()
10     {
11         $this->asEditor();
12         $page = Page::first();
13
14         $this->get($page->getUrl());
15
16         $this->assertDatabaseHas('views', [
17             'user_id' => $this->getEditor()->id,
18             'viewable_id' => $page->id,
19             'views' => 1
20         ]);
21
22         $exitCode = \Artisan::call('bookstack:clear-views');
23         $this->assertTrue($exitCode === 0, 'Command executed successfully');
24
25         $this->assertDatabaseMissing('views', [
26             'user_id' => $this->getEditor()->id
27         ]);
28     }
29 }