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