2021-06-26 11:23:15 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Commands;
|
2021-02-11 17:42:36 -05:00
|
|
|
|
|
|
|
use BookStack\Auth\User;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
class AddAdminCommandTest extends TestCase
|
|
|
|
{
|
|
|
|
public function test_add_admin_command()
|
|
|
|
{
|
|
|
|
$exitCode = \Artisan::call('bookstack:create-admin', [
|
2021-06-26 11:23:15 -04:00
|
|
|
'--email' => 'admintest@example.com',
|
|
|
|
'--name' => 'Admin Test',
|
2021-02-11 17:42:36 -05:00
|
|
|
'--password' => 'testing-4',
|
|
|
|
]);
|
|
|
|
$this->assertTrue($exitCode === 0, 'Command executed successfully');
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('users', [
|
|
|
|
'email' => 'admintest@example.com',
|
2021-06-26 11:23:15 -04:00
|
|
|
'name' => 'Admin Test',
|
2021-02-11 17:42:36 -05:00
|
|
|
]);
|
|
|
|
|
|
|
|
$this->assertTrue(User::query()->where('email', '=', 'admintest@example.com')->first()->hasSystemRole('admin'), 'User has admin role as expected');
|
|
|
|
$this->assertTrue(\Auth::attempt(['email' => 'admintest@example.com', 'password' => 'testing-4']), 'Password stored as expected');
|
|
|
|
}
|
2021-06-26 11:23:15 -04:00
|
|
|
}
|