]> BookStack Code Mirror - bookstack/blobdiff - tests/Commands/ClearViewsCommandTest.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / tests / Commands / ClearViewsCommandTest.php
index d553ead2e55c8038521d4ed156149f0f064b20b3..c9179089b20a7a9e73d7f2c55399157aaf3834b8 100644 (file)
@@ -1,11 +1,13 @@
-<?php namespace Tests\Commands;
+<?php
+
+namespace Tests\Commands;
 
 use BookStack\Entities\Models\Page;
+use Illuminate\Support\Facades\DB;
 use Tests\TestCase;
 
 class ClearViewsCommandTest extends TestCase
 {
-
     public function test_clear_views_command()
     {
         $this->asEditor();
@@ -14,16 +16,18 @@ class ClearViewsCommandTest extends TestCase
         $this->get($page->getUrl());
 
         $this->assertDatabaseHas('views', [
-            'user_id' => $this->getEditor()->id,
+            'user_id'     => $this->users->editor()->id,
             'viewable_id' => $page->id,
-            'views' => 1
+            'views'       => 1,
         ]);
 
+        DB::rollBack();
         $exitCode = \Artisan::call('bookstack:clear-views');
+        DB::beginTransaction();
         $this->assertTrue($exitCode === 0, 'Command executed successfully');
 
         $this->assertDatabaseMissing('views', [
-            'user_id' => $this->getEditor()->id
+            'user_id' => $this->users->editor()->id,
         ]);
     }
-}
\ No newline at end of file
+}