X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/2385a6c29b7b9c03123def135d3c6e95febaf9dd..refs/pull/692/head:/tests/CommandsTest.php diff --git a/tests/CommandsTest.php b/tests/CommandsTest.php index 5df82ee51..25516c317 100644 --- a/tests/CommandsTest.php +++ b/tests/CommandsTest.php @@ -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' => 'admintest@example.com', + '--name' => 'Admin Test', + '--password' => 'testing-4', + ]); + $this->assertTrue($exitCode === 0, 'Command executed successfully'); + + $this->assertDatabaseHas('users', [ + 'email' => 'admintest@example.com', + 'name' => 'Admin Test' + ]); + + $this->assertTrue(User::where('email', '=', 'admintest@example.com')->first()->hasSystemRole('admin'), 'User has admin role as expected'); + $this->assertTrue(\Auth::attempt(['email' => 'admintest@example.com', 'password' => 'testing-4']), 'Password stored as expected'); + } }