|
|
@ -3,6 +3,7 @@ |
|
|
namespace Tests\Feature\Auth; |
|
|
namespace Tests\Feature\Auth; |
|
|
|
|
|
|
|
|
use App\Entities\Users\User; |
|
|
use App\Entities\Users\User; |
|
|
|
|
|
use Notification; |
|
|
use Tests\TestCase; |
|
|
use Tests\TestCase; |
|
|
|
|
|
|
|
|
class ResetPasswordTest extends TestCase |
|
|
class ResetPasswordTest extends TestCase |
|
|
@ -10,21 +11,36 @@ class ResetPasswordTest extends TestCase |
|
|
/** @test */ |
|
|
/** @test */ |
|
|
public function user_can_reset_password_by_their_email() |
|
|
public function user_can_reset_password_by_their_email() |
|
|
{ |
|
|
{ |
|
|
// $user = factory(User::class)->create();
|
|
|
|
|
|
$user1 = factory(User::class)->create(['email' => 'testing@app.dev']); |
|
|
|
|
|
|
|
|
Notification::fake(); |
|
|
|
|
|
|
|
|
|
|
|
$user = factory(User::class)->create(['email' => 'testing@app.dev']); |
|
|
|
|
|
|
|
|
// Reset Request
|
|
|
|
|
|
$this->visit('password/reset'); |
|
|
|
|
|
$this->notSeeInDatabase('password_resets', [ |
|
|
$this->notSeeInDatabase('password_resets', [ |
|
|
'email' => 'testing@app.dev' |
|
|
|
|
|
|
|
|
'email' => 'testing@app.dev', |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
// Reset Request
|
|
|
|
|
|
$this->visit('password/reset'); |
|
|
$this->see(trans('auth.reset_password')); |
|
|
$this->see(trans('auth.reset_password')); |
|
|
$this->type('testing@app.dev', 'email'); |
|
|
$this->type('testing@app.dev', 'email'); |
|
|
$this->press(trans('auth.send_reset_password_link')); |
|
|
$this->press(trans('auth.send_reset_password_link')); |
|
|
|
|
|
|
|
|
$this->seePageIs('password/reset'); |
|
|
$this->seePageIs('password/reset'); |
|
|
$this->see(trans('passwords.sent')); |
|
|
$this->see(trans('passwords.sent')); |
|
|
$this->seeInDatabase('password_resets', [ |
|
|
$this->seeInDatabase('password_resets', [ |
|
|
'email' => 'testing@app.dev' |
|
|
|
|
|
|
|
|
'email' => 'testing@app.dev', |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
Notification::assertSentTo( |
|
|
|
|
|
$user, |
|
|
|
|
|
'Illuminate\Auth\Notifications\ResetPassword', |
|
|
|
|
|
function ($notification, $channels) use ($user) { |
|
|
|
|
|
|
|
|
|
|
|
$userPasswordReset = \DB::table('password_resets') |
|
|
|
|
|
->where('email', $user->email)->first(); |
|
|
|
|
|
|
|
|
|
|
|
return password_verify($notification->token, $userPasswordReset->token); |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |