X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/72c8b138e12a0596c56538e4c43e52847bfec2e0..refs/pull/3693/head:/tests/User/UserManagementTest.php diff --git a/tests/User/UserManagementTest.php b/tests/User/UserManagementTest.php index 3102b7bde..71d50e8d6 100644 --- a/tests/User/UserManagementTest.php +++ b/tests/User/UserManagementTest.php @@ -24,7 +24,7 @@ class UserManagementTest extends TestCase $resp = $this->asAdmin()->get('/settings/users'); $this->withHtml($resp)->assertElementContains('a[href="' . url('/http/source.bookstackapp.com/settings/users/create') . '"]', 'Add New User'); - $resp =$this->get('/settings/users/create'); + $resp = $this->get('/settings/users/create'); $this->withHtml($resp)->assertElementContains('form[action="' . url('/http/source.bookstackapp.com/settings/users/create') . '"]', 'Save'); $resp = $this->post('/settings/users/create', [ @@ -234,4 +234,28 @@ class UserManagementTest extends TestCase $this->assertDatabaseMissing('activities', ['type' => 'USER_CREATE']); } + + public function test_user_create_update_fails_if_locale_is_invalid() + { + $user = $this->getEditor(); + + // Too long + $resp = $this->asAdmin()->put($user->getEditUrl(), ['language' => 'this_is_too_long']); + $resp->assertSessionHasErrors(['language' => 'The language may not be greater than 15 characters.']); + session()->flush(); + + // Invalid characters + $resp = $this->put($user->getEditUrl(), ['language' => 'enassertSessionHasErrors(['language' => 'The language may only contain letters, numbers, dashes and underscores.']); + session()->flush(); + + // Both on create + $resp = $this->post('/settings/users/create', [ + 'language' => 'en 'My name', + 'email' => 'jimmy@example.com', + ]); + $resp->assertSessionHasErrors(['language' => 'The language may not be greater than 15 characters.']); + $resp->assertSessionHasErrors(['language' => 'The language may only contain letters, numbers, dashes and underscores.']); + } }