Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. /** @test */
  2.     public function security_can_reset_password()
  3.     {
  4.         Notification::fake();
  5.  
  6.         $this->post('api/security/reset', ['email' => 'test@testy.tt'])
  7.             ->assertResponseOk()
  8.             ->seeJson([
  9.                 'success' => true,
  10.                 'error' => false
  11.             ]);
  12.  
  13.         $token = DB::table('password_resets')
  14.             ->where('email', 'test@testy.tt')
  15.             ->orderBy('id', 'desc')
  16.             ->value('token');
  17.  
  18.         Notification::assertSentTo(
  19.             $this->security,
  20.             ResetPassword::class,
  21.             function ($notification, $channels) use ($token) {
  22.                 return $notification->token === $token;
  23.             }
  24.         );
  25.  
  26.         $this->post('api/security/resetting', [
  27.             'email' => 'test@testy.tt',
  28.             'token' => $token,
  29.             'password' => '87538753',
  30.             'password_confirmation' => '87538753'
  31.         ])
  32.             ->assertResponseOk()
  33.             ->seeJson([
  34.                 'success' => true,
  35.                 'error' => false
  36.             ]);
  37.  
  38.         $newHashedPassword = Security::whereEmail('test@testy.tt')->value('password');
  39.  
  40.         $this->assertTrue(Hash::check('87538753', $newHashedPassword));
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement