diff --git a/app/Console/Commands/CreateAdmin.php b/app/Console/Commands/CreateAdmin.php index e7aff3f92..c3faef79c 100644 --- a/app/Console/Commands/CreateAdmin.php +++ b/app/Console/Commands/CreateAdmin.php @@ -101,6 +101,7 @@ class CreateAdmin extends Command foreach ($this->options() as $key => $value) { $returnOpts[str_replace('-', '_', $key)] = $value; } + return $returnOpts; } } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index eebd4cd4f..3903682eb 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -77,8 +77,8 @@ class UserController extends Controller { $this->checkPermission('users-manage'); $validationRules = [ - 'name' => ['required'], - 'email' => ['required', 'email', 'unique:users,email'], + 'name' => ['required'], + 'email' => ['required', 'email', 'unique:users,email'], 'setting' => ['array'], ]; diff --git a/tests/Auth/UserInviteTest.php b/tests/Auth/UserInviteTest.php index 5b9b14e60..922a98ef3 100644 --- a/tests/Auth/UserInviteTest.php +++ b/tests/Auth/UserInviteTest.php @@ -21,8 +21,8 @@ class UserInviteTest extends TestCase $email = Str::random(16) . '@example.com'; $resp = $this->actingAs($admin)->post('/settings/users/create', [ - 'name' => 'Barry', - 'email' => $email, + 'name' => 'Barry', + 'email' => $email, 'send_invite' => 'true', ]); $resp->assertRedirect('/settings/users'); @@ -42,12 +42,12 @@ class UserInviteTest extends TestCase $email = Str::random(16) . '@example.com'; $resp = $this->actingAs($admin)->post('/settings/users/create', [ - 'name' => 'Barry', - 'email' => $email, + 'name' => 'Barry', + 'email' => $email, 'send_invite' => 'true', - 'setting' => [ + 'setting' => [ 'language' => 'de', - ] + ], ]); $resp->assertRedirect('/settings/users'); @@ -55,6 +55,7 @@ class UserInviteTest extends TestCase Notification::assertSentTo($newUser, UserInvite::class, function ($notification, $channels, $notifiable) { /** @var MailMessage $mail */ $mail = $notification->toMail($notifiable); + return 'Du wurdest eingeladen BookStack beizutreten!' === $mail->subject && 'Ein Konto wurde für Sie auf BookStack erstellt.' === $mail->greeting; }); @@ -80,7 +81,7 @@ class UserInviteTest extends TestCase ]); $setPasswordResp->assertSee('Password set, you should now be able to login using your set password to access BookStack!'); $newPasswordValid = auth()->validate([ - 'email' => $user->email, + 'email' => $user->email, 'password' => 'my test password', ]); $this->assertTrue($newPasswordValid); diff --git a/tests/Commands/CreateAdminCommandTest.php b/tests/Commands/CreateAdminCommandTest.php index 9aa4b8e38..1d8915b3a 100644 --- a/tests/Commands/CreateAdminCommandTest.php +++ b/tests/Commands/CreateAdminCommandTest.php @@ -11,14 +11,14 @@ class CreateAdminCommandTest extends TestCase public function test_standard_command_usage() { $this->artisan('bookstack:create-admin', [ - '--email' => 'admintest@example.com', - '--name' => 'Admin Test', + '--email' => 'admintest@example.com', + '--name' => 'Admin Test', '--password' => 'testing-4', ])->assertExitCode(0); $this->assertDatabaseHas('users', [ 'email' => 'admintest@example.com', - 'name' => 'Admin Test', + 'name' => 'Admin Test', ]); /** @var User $user */ @@ -30,14 +30,14 @@ class CreateAdminCommandTest extends TestCase public function test_providing_external_auth_id() { $this->artisan('bookstack:create-admin', [ - '--email' => 'admintest@example.com', - '--name' => 'Admin Test', + '--email' => 'admintest@example.com', + '--name' => 'Admin Test', '--external-auth-id' => 'xX_admin_Xx', ])->assertExitCode(0); $this->assertDatabaseHas('users', [ - 'email' => 'admintest@example.com', - 'name' => 'Admin Test', + 'email' => 'admintest@example.com', + 'name' => 'Admin Test', 'external_auth_id' => 'xX_admin_Xx', ]); @@ -50,13 +50,13 @@ class CreateAdminCommandTest extends TestCase { $this->artisan('bookstack:create-admin', [ '--email' => 'admintest@example.com', - '--name' => 'Admin Test', + '--name' => 'Admin Test', ])->expectsQuestion('Please specify a password for the new admin user (8 characters min)', 'hunter2000') ->assertExitCode(0); $this->assertDatabaseHas('users', [ 'email' => 'admintest@example.com', - 'name' => 'Admin Test', + 'name' => 'Admin Test', ]); $this->assertTrue(Auth::attempt(['email' => 'admintest@example.com', 'password' => 'hunter2000'])); }