3 namespace Tests\Commands;
5 use BookStack\Auth\User;
8 class AddAdminCommandTest extends TestCase
10 public function test_add_admin_command()
12 $exitCode = \Artisan::call('bookstack:create-admin', [
13 '--email' => 'admintest@example.com',
14 '--name' => 'Admin Test',
15 '--password' => 'testing-4',
17 $this->assertTrue($exitCode === 0, 'Command executed successfully');
19 $this->assertDatabaseHas('users', [
20 'email' => 'admintest@example.com',
21 'name' => 'Admin Test',
24 $this->assertTrue(User::query()->where('email', '=', 'admintest@example.com')->first()->hasSystemRole('admin'), 'User has admin role as expected');
25 $this->assertTrue(\Auth::attempt(['email' => 'admintest@example.com', 'password' => 'testing-4']), 'Password stored as expected');