Browse Source

Add notification fake (mock) to ResetPasswordTest

pull/1/head
Nafies Luthfi 8 years ago
parent
commit
d518836e92
  1. 3
      app/Entities/Subscriptions/SubscriptionsRepository.php
  2. 1
      config/app.php
  3. 28
      tests/Feature/Auth/ResetPasswordTest.php

3
app/Entities/Subscriptions/SubscriptionsRepository.php

@ -18,7 +18,8 @@ class SubscriptionsRepository extends BaseRepository
public function getSubscriptions($q, $customerId) public function getSubscriptions($q, $customerId)
{ {
return $this->model->orderBy('due_date')
return $this->model->orderBy('status_id', 'desc')
->orderBy('due_date')
->where(function ($query) use ($q, $customerId) { ->where(function ($query) use ($q, $customerId) {
if ($customerId) { if ($customerId) {
$query->where('customer_id', $customerId); $query->where('customer_id', $customerId);

1
config/app.php

@ -193,6 +193,7 @@ return [
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,
'Log' => Illuminate\Support\Facades\Log::class, 'Log' => Illuminate\Support\Facades\Log::class,
'Mail' => Illuminate\Support\Facades\Mail::class, 'Mail' => Illuminate\Support\Facades\Mail::class,
'Notification' => Illuminate\Support\Facades\Notification::class,
'Password' => Illuminate\Support\Facades\Password::class, 'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class, 'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class,

28
tests/Feature/Auth/ResetPasswordTest.php

@ -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);
}
);
} }
} }
Loading…
Cancel
Save