]> BookStack Code Mirror - bookstack/blob - tests/Commands/AddAdminCommandTest.php
6b03c86f92e46a68f4eac2b107bf0c7793ceaa3b
[bookstack] / tests / Commands / AddAdminCommandTest.php
1 <?php namespace Tests\Commands;
2
3 use BookStack\Auth\User;
4 use Tests\TestCase;
5
6 class AddAdminCommandTest extends TestCase
7 {
8     public function test_add_admin_command()
9     {
10         $exitCode = \Artisan::call('bookstack:create-admin', [
11             '--email' => '[email protected]',
12             '--name' => 'Admin Test',
13             '--password' => 'testing-4',
14         ]);
15         $this->assertTrue($exitCode === 0, 'Command executed successfully');
16
17         $this->assertDatabaseHas('users', [
18             'email' => '[email protected]',
19             'name' => 'Admin Test'
20         ]);
21
22         $this->assertTrue(User::query()->where('email', '=', '[email protected]')->first()->hasSystemRole('admin'), 'User has admin role as expected');
23         $this->assertTrue(\Auth::attempt(['email' => '[email protected]', 'password' => 'testing-4']), 'Password stored as expected');
24     }
25 }