Browse Source

Refactor change password testing and lang usage

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
f825c5c376
  1. 2
      app/Http/Controllers/AuthController.php
  2. 11
      config/app.php
  3. 3
      resources/lang/id/auth.php
  4. 38
      tests/Feature/Auth/MemberChangePasswordTest.php

2
app/Http/Controllers/AuthController.php

@ -101,7 +101,7 @@ class AuthController extends Controller {
$this->user->password = $input['password'];
$this->user->save();
flash()->success('Password berhasil diubah!');
flash()->success(trans('auth.password_changed'));
return redirect()->back();
}

11
config/app.php

@ -159,12 +159,8 @@ return [
App\Providers\OptionServiceProvider::class,
App\Providers\RouteServiceProvider::class,
BackupManager\Laravel\Laravel55ServiceProvider::class,
Laracasts\Flash\FlashServiceProvider::class,
Luthfi\FormField\FormFieldServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Riskihajar\Terbilang\TerbilangServiceProvider::class,
Spatie\Fractal\FractalServiceProvider::class,
],
/*
@ -212,15 +208,8 @@ return [
'View' => Illuminate\Support\Facades\View::class,
'Carbon' => Carbon\Carbon::class,
'Excel' => Maatwebsite\Excel\Facades\Excel::class,
'Fractal' => Spatie\Fractal\FractalFacade::class,
'Option' => App\Services\Facades\Option::class,
'FormField' => Luthfi\FormField\FormFieldFacade::class,
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
'Terbilang' => Riskihajar\Terbilang\Facades\Terbilang::class,
],
];

3
resources/lang/id/auth.php

@ -23,6 +23,7 @@ return [
'have_an_account' => 'Saya sudah punya Akun',
'need_account' => 'Belum punya Akun?',
'change_password' => 'Ganti Password',
'password_changed' => 'Password berhasil diubah.',
'forgot_password' => 'Lupa Password?',
'reset_password' => 'Reset Password',
'password_confirmation' => 'Ulangi Password',
@ -30,4 +31,6 @@ return [
'new_password' => 'Password Baru',
'new_password_confirmation' => 'Ulangi Password Baru',
'send_reset_password_link' => 'Kirim Link Reset Password',
'old_password_failed' => 'Password lama tidak cocok!',
'welcome' => 'Selamat datang kembali :name.',
];

38
tests/Feature/Auth/MemberChangePasswordTest.php

@ -15,27 +15,29 @@ class MemberChangePasswordTest extends TestCase
$this->actingAs($user);
$this->visit(route('home'));
$this->seePageIs(route('home'));
$this->click(trans('auth.change_password'));
$this->type('member1', 'old_password');
$this->type('rahasia', 'password');
$this->type('rahasia', 'password_confirmation');
$this->press(trans('auth.change_password'));
$this->see('Password lama tidak cocok');
$this->submitForm(trans('auth.change_password'), [
'old_password' => 'member1',
'password' => 'rahasia',
'password_confirmation' => 'rahasia',
]);
$this->see(trans('auth.old_password_failed'));
$this->assertTrue(
app('hash')->check('member', $user->password),
'The password shouldn\'t changed!'
);
$this->type('member', 'old_password');
$this->type('rahasia', 'password');
$this->type('rahasia', 'password_confirmation');
$this->press(trans('auth.change_password'));
$this->see('Password berhasil diubah');
$this->submitForm(trans('auth.change_password'), [
'old_password' => 'member',
'password' => 'rahasia',
'password_confirmation' => 'rahasia',
]);
$this->see(trans('auth.password_changed'));
// Logout and login using new Password
$this->click('Keluar');
$this->seePageIs(route('auth.login'));
$this->type($user->email, 'email');
$this->type('rahasia', 'password');
$this->press('Login');
$this->seePageIs(route('home'));
$this->assertTrue(
app('hash')->check('rahasia', $user->password),
'The password should changed!'
);
}
}
Loading…
Cancel
Save