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