Browse Source

Passed password reset test

pull/1/head
Nafies Luthfi 9 years ago
parent
commit
025cb1a0ef
  1. 4
      routes/web/account.php
  2. 62
      tests/auth/MemberResetPasswordTest.php
  3. 29
      tests/auth/ResetPasswordTest.php

4
routes/web/account.php

@ -18,5 +18,5 @@ Route::group(['middleware' => 'web','as'=>'auth.'], function() {
// Password Reset Routes...
Route::get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('auth.reset-request');
Route::post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('auth.reset-email');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('auth.reset-password');
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('auth.reset-password');
Route::get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('password/reset', 'Auth\ResetPasswordController@reset')->name('reset-password');

62
tests/auth/MemberResetPasswordTest.php

@ -1,62 +0,0 @@
<?php
use App\Entities\Users\User;
class MemberResetPasswordTest extends TestCase
{
/** @test */
public function member_can_reset_password_by_their_email()
{
// $user = factory(User::class)->create();
// // Reset Request
// $this->visit(route('auth.reset-request'));
// $this->notSeeInDatabase('password_resets', [
// 'email' => $user->email
// ]);
// $this->see('Reset Password');
// $this->type($user->email,'email');
// $this->press('Kirim Link Reset Password');
// $this->seePageIs(route('auth.reset-request'));
// $this->see('Kami sudah mengirim email');
// $this->seeInDatabase('password_resets', [
// 'email' => $user->email
// ]);
// // Reset Action
// $resetData = DB::table('password_resets')->where('email', $user->email)->first();
// $token = $resetData->token;
// $this->visit('password/reset/' . $token);
// $this->see('Reset Password');
// $this->see('Password Baru');
// // Enter an invalid email
// $this->type('mail@mail.com','email');
// $this->type('rahasia','password');
// $this->type('rahasia','password_confirmation');
// $this->press('Reset Password');
// $this->see('Kami tidak dapat menemukan pengguna dengan email tersebut');
// // Enter a valid email
// $this->type($user->email,'email');
// $this->type('rahasia','password');
// $this->type('rahasia','password_confirmation');
// $this->press('Reset Password');
// $this->seePageIs(route('home'));
// $this->notSeeInDatabase('password_resets', [
// 'email' => $user->email
// ]);
// // Logout and login using new Password
// $this->click('Keluar');
// $this->seePageIs(route('auth.login'));
// $this->type($user->username,'username');
// $this->type('rahasia','password');
// $this->press('Login');
// $this->seePageIs(route('home'));
}
}

29
tests/auth/ResetPasswordTest.php

@ -0,0 +1,29 @@
<?php
use App\Entities\Users\User;
class ResetPasswordTest extends TestCase
{
/** @test */
public function user_can_reset_password_by_their_email()
{
// $user = factory(User::class)->create();
$user1 = factory(User::class)->create(['username' => '123456', 'email' => 'testing@app.dev']);
// Reset Request
$this->visit('password/reset');
$this->notSeeInDatabase('password_resets', [
'email' => 'testing@app.dev'
]);
$this->see(trans('auth.reset_password'));
$this->type('testing@app.dev','email');
$this->press(trans('auth.send_reset_password_link'));
$this->seePageIs('password/reset');
$this->see(trans('passwords.sent'));
$this->seeInDatabase('password_resets', [
'email' => 'testing@app.dev'
]);
}
}
Loading…
Cancel
Save