review changes

This commit is contained in:
msquare 2020-11-24 17:27:21 +01:00 committed by Igor Scheller
parent 27331b4cf6
commit 39f96783cf
17 changed files with 223 additions and 147 deletions

View File

@ -75,7 +75,7 @@ function user_delete_controller()
&& $auth->verifyPassword($user, $request->postData('password')) && $auth->verifyPassword($user, $request->postData('password'))
)) { )) {
$valid = false; $valid = false;
error(__('Your password is incorrect. Please try it again.')); error(__('auth.password.error'));
} }
if ($valid) { if ($valid) {

View File

@ -321,8 +321,9 @@ function form_password($name, $label, $disabled = false)
return form_element( return form_element(
$label, $label,
sprintf( sprintf(
'<input class="form-control" id="form_%1$s" type="password" name="%1$s" value=""%s/>', '<input class="form-control" id="form_%1$s" type="password" name="%1$s" minlength="%2$s" value=""%3$s/>',
$name, $name,
config('min_password_length'),
$disabled $disabled
), ),
'form_' . $name 'form_' . $name

View File

@ -7,6 +7,7 @@ use Engelsystem\Models\Worklog;
use Engelsystem\Renderer\Renderer; use Engelsystem\Renderer\Renderer;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Engelsystem\Controllers\SettingsController;
/** /**
* Renders user settings page * Renders user settings page
@ -44,6 +45,7 @@ function User_settings_view(
'pages/settings/settings.twig', 'pages/settings/settings.twig',
[ [
'title' => 'settings.profile', 'title' => 'settings.profile',
'settings_menu' => app()->make(SettingsController::class)->settingsMenu(),
'content' => 'content' =>
msg() msg()
. div('row', [ . div('row', [

View File

@ -27,7 +27,10 @@ msgid "validation.email.email"
msgstr "Die E-Mail-Adresse ist nicht gültig." msgstr "Die E-Mail-Adresse ist nicht gültig."
msgid "validation.password.min" msgid "validation.password.min"
msgstr "Dein angegebenes Passwort ist zu kurz." msgstr "Dein neues Passwort ist zu kurz."
msgid "validation.new_password.min"
msgstr "Dein neues Passwort ist zu kurz."
msgid "validation.password.confirmed" msgid "validation.password.confirmed"
msgstr "Deine Passwörter stimmen nicht überein." msgstr "Deine Passwörter stimmen nicht überein."

View File

@ -775,7 +775,7 @@ msgid "You cannot delete yourself."
msgstr "Du kannst Dich nicht selber löschen." msgstr "Du kannst Dich nicht selber löschen."
#: includes/controller/users_controller.php:76 #: includes/controller/users_controller.php:76
msgid "Your password is incorrect. Please try it again." msgid "auth.password.error"
msgstr "Dein Passwort stimmt nicht. Bitte probiere es nochmal." msgstr "Dein Passwort stimmt nicht. Bitte probiere es nochmal."
#: includes/controller/users_controller.php:85 #: includes/controller/users_controller.php:85
@ -1578,10 +1578,6 @@ msgstr "Bitte gib Deine E-Mail-Adresse ein."
msgid "Please select your shirt size." msgid "Please select your shirt size."
msgstr "Bitte wähle Deine T-Shirt Größe." msgstr "Bitte wähle Deine T-Shirt Größe."
#: includes/pages/guest_login.php:124 includes/pages/user_settings.php:117
msgid "Your passwords don't match."
msgstr "Deine Passwörter stimmen nicht überein."
#: includes/pages/guest_login.php:129 #: includes/pages/guest_login.php:129
#, php-format #, php-format
msgid "Your password is too short (please use at least %s characters)." msgid "Your password is too short (please use at least %s characters)."
@ -2491,22 +2487,6 @@ msgstr "Geplanter Abreisetag"
msgid "Please visit the angeltypes page to manage your angeltypes." msgid "Please visit the angeltypes page to manage your angeltypes."
msgstr "Bitte benutze die Engeltypen-Seite um deine Engeltypen zu verwalten." msgstr "Bitte benutze die Engeltypen-Seite um deine Engeltypen zu verwalten."
#: includes/view/User_view.php:89
msgid "Here you can change your password."
msgstr "Hier kannst Du Dein Passwort ändern."
#: includes/view/User_view.php:90
msgid "Old password:"
msgstr "Altes Passwort:"
#: includes/view/User_view.php:91
msgid "New password:"
msgstr "Neues Passwort:"
#: includes/view/User_view.php:92
msgid "Password confirmation:"
msgstr "Passwort wiederholen:"
#: includes/view/User_view.php:96 #: includes/view/User_view.php:96
msgid "Here you can choose your color settings:" msgid "Here you can choose your color settings:"
msgstr "Hier kannst Du das Aussehen auswählen:" msgstr "Hier kannst Du das Aussehen auswählen:"
@ -2896,6 +2876,9 @@ msgstr "Treffen"
msgid "news.edit.message" msgid "news.edit.message"
msgstr "Nachricht" msgstr "Nachricht"
msgid "news.preview"
msgstr "Vorschau"
msgid "form.search" msgid "form.search"
msgstr "Suchen" msgstr "Suchen"
@ -2918,8 +2901,23 @@ msgstr "Einstellungen"
msgid "settings.password" msgid "settings.password"
msgstr "Passwort" msgstr "Passwort"
msgid "settings.password.info"
msgstr "Hier kannst Du Dein Passwort ändern."
msgid "settings.password.password"
msgstr "Altes Passwort"
msgid "settings.password.new_password"
msgstr "Neues Passwort"
msgid "settings.password.new_password2"
msgstr "Passwort wiederholen"
msgid "settings.password.success"
msgstr "Passwort wurde erfolgreich geändert."
msgid "settings.oauth" msgid "settings.oauth"
msgstr "Single-Sign-On" msgstr "Single Sign-On"
msgid "settings.oauth.identity-provider" msgid "settings.oauth.identity-provider"
msgstr "Login-Dienst" msgstr "Login-Dienst"

View File

@ -25,7 +25,10 @@ msgid "validation.email.email"
msgstr "This email address is not valid." msgstr "This email address is not valid."
msgid "validation.password.min" msgid "validation.password.min"
msgstr "Your password is too short." msgstr "Your new password is too short."
msgid "validation.new_password.min"
msgstr "Your new password is too short."
msgid "validation.password.confirmed" msgid "validation.password.confirmed"
msgstr "Your passwords are not equal." msgstr "Your passwords are not equal."

View File

@ -21,6 +21,8 @@ msgstr ""
#~ msgid "auth.no-password" #~ msgid "auth.no-password"
#~ msgstr "Please enter a password." #~ msgstr "Please enter a password."
msgid "auth.password.error"
msgstr "Your password is incorrect. Please try it again."
msgid "form.submit" msgid "form.submit"
msgstr "Submit" msgstr "Submit"
@ -163,6 +165,9 @@ msgstr "Meeting"
msgid "news.edit.message" msgid "news.edit.message"
msgstr "Message" msgstr "Message"
msgid "news.preview"
msgstr "Preview"
msgid "form.search" msgid "form.search"
msgstr "Search" msgstr "Search"
@ -184,8 +189,23 @@ msgstr "Settings"
msgid "settings.password" msgid "settings.password"
msgstr "Password" msgstr "Password"
msgid "settings.password.info"
msgstr "Here you can change your password."
msgid "settings.password.password"
msgstr "Old password"
msgid "settings.password.new_password"
msgstr "New passwort"
msgid "settings.password.new_password2"
msgstr "Password confirmation"
msgid "settings.password.success"
msgstr "Password was changed successfully."
msgid "settings.oauth" msgid "settings.oauth"
msgstr "Single-Sign-On" msgstr "Single Sign-On"
msgid "settings.oauth.identity-provider" msgid "settings.oauth.identity-provider"
msgstr "Identity provider" msgstr "Identity provider"

View File

@ -23,3 +23,7 @@
{{ label }} {{ label }}
</a> </a>
{% endmacro %} {% endmacro %}
{% macro info(text) %}
<span class="help-block">{{ _self.glyphicon('info-sign') }}{{ text }}</span>
{%- endmacro %}

View File

@ -7,6 +7,7 @@
type="{{ type|default('text') }}" class="form-control" type="{{ type|default('text') }}" class="form-control"
id="{{ name }}" name="{{ name }}" id="{{ name }}" name="{{ name }}"
value="{{ opt.value|default('')|escape('html_attr') }}" value="{{ opt.value|default('')|escape('html_attr') }}"
{%- if opt.min is defined %} minlength="{{ opt.min }}"{% endif %}
{%- if opt.required|default(false) %} {%- if opt.required|default(false) %}
required required
{%- endif -%} {%- endif -%}
@ -77,8 +78,3 @@
{% macro submit(label, opt) %} {% macro submit(label, opt) %}
{{ _self.button(label|default(__('form.submit')), opt|default({})|merge({'type': 'submit'})) }} {{ _self.button(label|default(__('form.submit')), opt|default({})|merge({'type': 'submit'})) }}
{%- endmacro %} {%- endmacro %}
{% macro info(text) %}
{% import 'macros/base.twig' as m %}
<span class="help-block">{{ m.glyphicon('info-sign') }}{{ text }}</span>
{%- endmacro %}

View File

@ -62,7 +62,7 @@
{% if news %} {% if news %}
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h2>{{ __('Preview') }}</h2> <h2>{{ __('news.preview') }}</h2>
<div class="panel {% if not news.is_meeting %}panel-default{% else %}panel-info{% endif %}"> <div class="panel {% if not news.is_meeting %}panel-default{% else %}panel-info{% endif %}">
<div class="panel-heading"> <div class="panel-heading">

View File

@ -7,8 +7,8 @@
<form action="" enctype="multipart/form-data" method="post"> <form action="" enctype="multipart/form-data" method="post">
{{ csrf() }} {{ csrf() }}
{{ f.input('password', __('Password'), 'password', {'required': true}) }} {{ f.input('password', __('Password'), 'password', {'min': min_length, 'required': true}) }}
{{ f.input('password_confirmation', __('Confirm password'), 'password', {'required': true}) }} {{ f.input('password_confirmation', __('Confirm password'), 'password', {'min': min_length, 'required': true}) }}
<div class="form-group"> <div class="form-group">
{{ f.submit(__('Save')) }} {{ f.submit(__('Save')) }}

View File

@ -10,24 +10,24 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
{{ f.info(__('Here you can change your password.')) }} {{ m.info(__('settings.password.info')) }}
{{ f.input( {{ f.input(
'password', 'password',
__('Old password:'), __('settings.password.password'),
'password', 'password',
{'required': true} {'required': true}
) }} ) }}
{{ f.input( {{ f.input(
'new_password', 'new_password',
__('New password:'), __('settings.password.new_password'),
'password', 'password',
{'required': true} {'min': min_length, 'required': true}
) }} ) }}
{{ f.input( {{ f.input(
'new_password2', 'new_password2',
__('Password confirmation:'), __('settings.password.new_password2'),
'password', 'password',
{'required': true} {'min': min_length, 'required': true}
) }} ) }}
{{ f.submit() }} {{ f.submit() }}
</div> </div>

View File

@ -12,13 +12,9 @@
<div class="row"> <div class="row">
<div class="col-md-3 settings-menu"> <div class="col-md-3 settings-menu">
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
{% for url,title in { {% for url,title in settings_menu %}
(url('/user-settings')): __('settings.profile'),
(url('/settings/password')): __('settings.password'),
(url('/settings/oauth')): __('settings.oauth'),
} %}
<li{% if url == request.url() %} class="active"{% endif %}> <li{% if url == request.url() %} class="active"{% endif %}>
<a href="{{ url }}">{{ title }}</a> <a href="{{ url }}">{{ __(title) }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -103,7 +103,10 @@ class PasswordResetController extends BaseController
{ {
$this->requireToken($request); $this->requireToken($request);
return $this->showView('pages/password/reset-form'); return $this->showView(
'pages/password/reset-form',
['min_length' => config('min_password_length')]
);
} }
/** /**

View File

@ -45,11 +45,11 @@ class SettingsController extends BaseController
Redirector $redirector, Redirector $redirector,
Response $response Response $response
) { ) {
$this->auth = $auth; $this->auth = $auth;
$this->config = $config; $this->config = $config;
$this->log = $log; $this->log = $log;
$this->redirect = $redirector; $this->redirect = $redirector;
$this->response = $response; $this->response = $response;
} }
/** /**
@ -58,31 +58,38 @@ class SettingsController extends BaseController
public function password(): Response public function password(): Response
{ {
return $this->response->withView( return $this->response->withView(
'pages/settings/password.twig', 'pages/settings/password',
$this->getNotifications() [
'settings_menu' => $this->settingsMenu(),
'min_length' => config('min_password_length')
] + $this->getNotifications()
); );
} }
/** /**
* @param Request $request
* @return Response * @return Response
*/ */
public function savePassword(Request $request): Response public function savePassword(Request $request): Response
{ {
$user = $this->auth->user(); $user = $this->auth->user();
if ( $minLength = config('min_password_length');
!$request->has('password') $data = $this->validate($request, [
|| !$this->auth->verifyPassword($user, $request->postData('password')) 'password' => 'required',
) { 'new_password' => 'required|min:' . $minLength,
$this->addNotification('-> not OK. Please try again.', 'errors'); 'new_password2' => 'required'
} elseif (strlen($request->postData('new_password')) < config('min_password_length')) { ]);
$this->addNotification('Your password is to short (please use at least 6 characters).', 'errors');
} elseif ($request->postData('new_password') != $request->postData('new_password2')) {
$this->addNotification('Your passwords don\'t match.', 'errors');
} else {
$this->auth->setPassword($user, $request->postData('new_password'));
$this->addNotification('Password saved.'); if (!$this->auth->verifyPassword($user, $data['password'])) {
$this->addNotification('auth.password.error', 'errors');
} elseif ($data['new_password'] != $data['new_password2']) {
$this->addNotification('validation.password.confirmed', 'errors');
} else {
$this->auth->setPassword($user, $data['new_password']);
$this->addNotification('settings.password.success');
$this->log->info('User set new password.'); $this->log->info('User set new password.');
} }
@ -100,10 +107,27 @@ class SettingsController extends BaseController
} }
return $this->response->withView( return $this->response->withView(
'pages/settings/oauth.twig', 'pages/settings/oauth',
[ [
'settings_menu' => $this->settingsMenu(),
'providers' => $providers, 'providers' => $providers,
] + $this->getNotifications(), ] + $this->getNotifications(),
); );
} }
/**
* @return array
*/
public function settingsMenu(): array
{
$menu = [
url('/user-settings') => 'settings.profile',
url('/settings/password') => 'settings.password'
];
if (!empty(config('oauth'))) {
$menu[url('/settings/oauth')] = 'settings.oauth';
}
return $menu;
}
} }

View File

@ -104,6 +104,7 @@ class PasswordResetControllerTest extends TestCase
{ {
$this->initDatabase(); $this->initDatabase();
$this->app->instance('config', new Config(['min_password_length' => 3]));
$user = $this->createUser(); $user = $this->createUser();
$token = $this->createToken($user); $token = $this->createToken($user);
$request = new Request([], [], ['token' => $token->token]); $request = new Request([], [], ['token' => $token->token]);

View File

@ -19,6 +19,8 @@ use Psr\Log\Test\TestLogger;
use Engelsystem\Http\UrlGeneratorInterface; use Engelsystem\Http\UrlGeneratorInterface;
use Engelsystem\Http\UrlGenerator; use Engelsystem\Http\UrlGenerator;
use Engelsystem\Models\User\User; use Engelsystem\Models\User\User;
use Engelsystem\Http\Validation\Validator;
use Engelsystem\Http\Exceptions\ValidationException;
class SettingsControllerTest extends TestCase class SettingsControllerTest extends TestCase
{ {
@ -51,7 +53,7 @@ class SettingsControllerTest extends TestCase
$this->response->expects($this->once()) $this->response->expects($this->once())
->method('withView') ->method('withView')
->willReturnCallback(function ($view, $data) { ->willReturnCallback(function ($view, $data) {
$this->assertEquals('pages/settings/password.twig', $view); $this->assertEquals('pages/settings/password', $view);
return $this->response; return $this->response;
}); });
@ -73,26 +75,20 @@ class SettingsControllerTest extends TestCase
]; ];
$this->request = $this->request->withParsedBody($body); $this->request = $this->request->withParsedBody($body);
$this->auth->expects($this->once()) $this->setExpects($this->auth, 'user', null, $this->user, $this->once());
->method('user') $this->setExpects($this->auth, 'verifyPassword', [$this->user, 'password'], true, $this->once());
->willReturn($this->user); $this->setExpects($this->auth, 'setPassword', [$this->user, 'newpassword'], null, $this->once());
$this->setExpects(
$this->auth->expects($this->once()) $this->response,
->method('verifyPassword') 'redirectTo',
->with($this->user, 'password') ['http://localhost/settings/password'],
->willReturn(true); $this->response,
$this->once()
$this->auth->expects($this->once()) );
->method('setPassword')
->with($this->user, 'newpassword');
$this->response->expects($this->once())
->method('redirectTo')
->with('http://localhost/settings/password')
->willReturn($this->response);
/** @var SettingsController $controller */ /** @var SettingsController $controller */
$controller = $this->app->make(SettingsController::class); $controller = $this->app->make(SettingsController::class);
$controller->setValidator(new Validator());
$controller->savePassword($this->request); $controller->savePassword($this->request);
$this->assertTrue($this->log->hasInfoThatContains('User set new password.')); $this->assertTrue($this->log->hasInfoThatContains('User set new password.'));
@ -100,7 +96,7 @@ class SettingsControllerTest extends TestCase
/** @var Session $session */ /** @var Session $session */
$session = $this->app->get('session'); $session = $this->app->get('session');
$messages = $session->get('messages'); $messages = $session->get('messages');
$this->assertEquals('Password saved.', $messages[0]); $this->assertEquals('settings.password.success', $messages[0]);
} }
/** /**
@ -115,31 +111,26 @@ class SettingsControllerTest extends TestCase
]; ];
$this->request = $this->request->withParsedBody($body); $this->request = $this->request->withParsedBody($body);
$this->auth->expects($this->once()) $this->setExpects($this->auth, 'user', null, $this->user, $this->once());
->method('user') $this->setExpects($this->auth, 'verifyPassword', [$this->user, 'wrongpassword'], false, $this->once());
->willReturn($this->user); $this->setExpects($this->auth, 'setPassword', null, null, $this->never());
$this->setExpects(
$this->auth->expects($this->once()) $this->response,
->method('verifyPassword') 'redirectTo',
->with($this->user, 'wrongpassword') ['http://localhost/settings/password'],
->willReturn(false); $this->response,
$this->once()
$this->auth->expects($this->never()) );
->method('setPassword');
$this->response->expects($this->once())
->method('redirectTo')
->with('http://localhost/settings/password')
->willReturn($this->response);
/** @var SettingsController $controller */ /** @var SettingsController $controller */
$controller = $this->app->make(SettingsController::class); $controller = $this->app->make(SettingsController::class);
$controller->setValidator(new Validator());
$controller->savePassword($this->request); $controller->savePassword($this->request);
/** @var Session $session */ /** @var Session $session */
$session = $this->app->get('session'); $session = $this->app->get('session');
$errors = $session->get('errors'); $errors = $session->get('errors');
$this->assertEquals('-> not OK. Please try again.', $errors[0]); $this->assertEquals('auth.password.error', $errors[0]);
} }
/** /**
@ -154,70 +145,69 @@ class SettingsControllerTest extends TestCase
]; ];
$this->request = $this->request->withParsedBody($body); $this->request = $this->request->withParsedBody($body);
$this->auth->expects($this->once()) $this->setExpects($this->auth, 'user', null, $this->user, $this->once());
->method('user') $this->setExpects($this->auth, 'verifyPassword', [$this->user, 'password'], true, $this->once());
->willReturn($this->user); $this->setExpects($this->auth, 'setPassword', null, null, $this->never());
$this->setExpects(
$this->auth->expects($this->once()) $this->response,
->method('verifyPassword') 'redirectTo',
->with($this->user, 'password') ['http://localhost/settings/password'],
->willReturn(true); $this->response,
$this->once()
$this->auth->expects($this->never()) );
->method('setPassword');
$this->response->expects($this->once())
->method('redirectTo')
->with('http://localhost/settings/password')
->willReturn($this->response);
/** @var SettingsController $controller */ /** @var SettingsController $controller */
$controller = $this->app->make(SettingsController::class); $controller = $this->app->make(SettingsController::class);
$controller->setValidator(new Validator());
$controller->savePassword($this->request); $controller->savePassword($this->request);
/** @var Session $session */ /** @var Session $session */
$session = $this->app->get('session'); $session = $this->app->get('session');
$errors = $session->get('errors'); $errors = $session->get('errors');
$this->assertEquals('Your passwords don\'t match.', $errors[0]); $this->assertEquals('validation.password.confirmed', $errors[0]);
}
/**
* @return array
*/
public function savePasswordValidationProvider(): array
{
return [
[null, 'newpassword', 'newpassword'],
['password', null, 'newpassword'],
['password', 'newpassword', null],
['password', 'short', 'short']
];
} }
/** /**
* @covers \Engelsystem\Controllers\SettingsController::savePassword * @covers \Engelsystem\Controllers\SettingsController::savePassword
* @dataProvider savePasswordValidationProvider
* @param string $password
* @param string $new_password
* @param string $new_password2
*/ */
public function testSavePasswordInvalidNewPassword() public function testSavePasswordValidation(
{ ?string $password,
?string $newPassword,
?string $newPassword2
) {
$body = [ $body = [
'password' => 'password', 'password' => $password,
'new_password' => 'short', 'new_password' => $newPassword,
'new_password2' => 'short' 'new_password2' => $newPassword2
]; ];
$this->request = $this->request->withParsedBody($body); $this->request = $this->request->withParsedBody($body);
$this->auth->expects($this->once()) $this->setExpects($this->auth, 'user', null, $this->user, $this->once());
->method('user') $this->setExpects($this->auth, 'setPassword', null, null, $this->never());
->willReturn($this->user);
$this->auth->expects($this->once()) $this->expectException(ValidationException::class);
->method('verifyPassword')
->with($this->user, 'password')
->willReturn(true);
$this->auth->expects($this->never())
->method('setPassword');
$this->response->expects($this->once())
->method('redirectTo')
->with('http://localhost/settings/password')
->willReturn($this->response);
/** @var SettingsController $controller */ /** @var SettingsController $controller */
$controller = $this->app->make(SettingsController::class); $controller = $this->app->make(SettingsController::class);
$controller->setValidator(new Validator());
$controller->savePassword($this->request); $controller->savePassword($this->request);
/** @var Session $session */
$session = $this->app->get('session');
$errors = $session->get('errors');
$this->assertEquals('Your password is to short (please use at least 6 characters).', $errors[0]);
} }
/** /**
@ -231,7 +221,7 @@ class SettingsControllerTest extends TestCase
$this->response->expects($this->once()) $this->response->expects($this->once())
->method('withView') ->method('withView')
->willReturnCallback(function ($view, $data) use ($providers) { ->willReturnCallback(function ($view, $data) use ($providers) {
$this->assertEquals('pages/settings/oauth.twig', $view); $this->assertEquals('pages/settings/oauth', $view);
$this->assertArrayHasKey('information', $data); $this->assertArrayHasKey('information', $data);
$this->assertArrayHasKey('providers', $data); $this->assertArrayHasKey('providers', $data);
$this->assertEquals($providers, $data['providers']); $this->assertEquals($providers, $data['providers']);
@ -258,6 +248,40 @@ class SettingsControllerTest extends TestCase
$controller->oauth(); $controller->oauth();
} }
/**
* @covers \Engelsystem\Controllers\SettingsController::settingsMenu
*/
public function testSettingsMenuWithOAuth()
{
$providers = ['foo' => ['lorem' => 'ipsum']];
config(['oauth' => $providers]);
/** @var SettingsController $controller */
$controller = $this->app->make(SettingsController::class);
$this->assertEquals([
'http://localhost/user-settings' => 'settings.profile',
'http://localhost/settings/password' => 'settings.password',
'http://localhost/settings/oauth' => 'settings.oauth'
], $controller->settingsMenu());
}
/**
* @covers \Engelsystem\Controllers\SettingsController::settingsMenu
*/
public function testSettingsMenuWithoutOAuth()
{
config(['oauth' => []]);
/** @var SettingsController $controller */
$controller = $this->app->make(SettingsController::class);
$this->assertEquals([
'http://localhost/user-settings' => 'settings.profile',
'http://localhost/settings/password' => 'settings.password'
], $controller->settingsMenu());
}
/** /**
* Setup environment * Setup environment
*/ */
@ -279,6 +303,7 @@ class SettingsControllerTest extends TestCase
$this->app->instance(Response::class, $this->response); $this->app->instance(Response::class, $this->response);
$this->app->bind(UrlGeneratorInterface::class, UrlGenerator::class); $this->app->bind(UrlGeneratorInterface::class, UrlGenerator::class);
$this->app->bind('http.urlGenerator', UrlGenerator::class);
$this->log = new TestLogger(); $this->log = new TestLogger();
$this->app->instance(LoggerInterface::class, $this->log); $this->app->instance(LoggerInterface::class, $this->log);