]> BookStack Code Mirror - bookstack/blobdiff - tests/CommandsTest.php
Corrected the keys for okta auth
[bookstack] / tests / CommandsTest.php
index 5df82ee513aeef49c2bc6d5f837539f5bc46c37c..25516c31732bd04ae2ba9f6dc8743305b6b245be 100644 (file)
@@ -3,6 +3,7 @@
 use BookStack\JointPermission;
 use BookStack\Page;
 use BookStack\Repos\EntityRepo;
+use BookStack\User;
 
 class CommandsTest extends TestCase
 {
@@ -99,4 +100,22 @@ class CommandsTest extends TestCase
 
         $this->assertDatabaseHas('joint_permissions', ['entity_id' => $page->id]);
     }
+
+    public function test_add_admin_command()
+    {
+        $exitCode = \Artisan::call('bookstack:create-admin', [
+            '--email' => '[email protected]',
+            '--name' => 'Admin Test',
+            '--password' => 'testing-4',
+        ]);
+        $this->assertTrue($exitCode === 0, 'Command executed successfully');
+
+        $this->assertDatabaseHas('users', [
+            'email' => '[email protected]',
+            'name' => 'Admin Test'
+        ]);
+
+        $this->assertTrue(User::where('email', '=', '[email protected]')->first()->hasSystemRole('admin'), 'User has admin role as expected');
+        $this->assertTrue(\Auth::attempt(['email' => '[email protected]', 'password' => 'testing-4']), 'Password stored as expected');
+    }
 }