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', [
12 '--name' => 'Admin Test',
13 '--password' => 'testing-4',
15 $this->assertTrue($exitCode === 0, 'Command executed successfully');
17 $this->assertDatabaseHas('users', [
19 'name' => 'Admin Test'
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');