Inheritance: extends Illuminate\Support\Facades\Facade
Example #1
0
 /**
  * @test
  */
 public function it_allow_to_verificaiton_after_registration()
 {
     // remove all users
     User::truncate();
     $this->assertNull(User::first());
     // create verified user
     $formUser = factory(User::class, 'form')->make(['verified' => 1, 'password' => bcrypt('passwordOne')]);
     $formUser->save();
     $this->assertTrue(Auth::guest(), 'User is logged in');
     // send reset link
     MailThief::hijack();
     $this->visit('/password/reset')->type($formUser->email, 'email')->press(trans('user::user.reset_password'))->see('alert-success');
     $password_resets = DB::table('password_resets')->where('email', $formUser->email)->first();
     $this->assertNotNull($password_resets);
     // check mail
     $this->assertTrue(MailThief::hasMessageFor($formUser->email));
     $this->assertEquals('Reset Password', MailThief::lastMessage()->subject);
     $emailContent = MailThief::lastMessage()->getBody();
     $this->assertTrue(strpos($emailContent, $password_resets->token) !== false);
     // click link
     $this->visit('/password/reset/' . $password_resets->token)->see(trans('user::user.reset_password'))->type($formUser->email, 'email')->type('passwordTwo', 'password')->type('passwordTwo', 'password_confirmation')->press(trans('user::user.reset_password'))->see('alert-success');
     $this->assertFalse(Auth::guest(), 'User is NOT logged in');
     // check new password
     $passwordCorrect = app('hash')->check('passwordTwo', User::first()->password);
     $this->assertTrue($passwordCorrect, 'Password not equals with bcrypt');
 }
Example #2
0
 /**
  * @test
  */
 public function it_allow_to_verificaiton_after_registration()
 {
     MailThief::hijack();
     // remove all users
     User::truncate();
     $this->assertNull(User::first());
     // register a user
     Honeypot::disable();
     $formUser = $this->registerUser();
     $this->assertTrue(Auth::guest(), 'User is logged in');
     // check database
     $user = User::first();
     $this->assertEquals('0', $user->verified);
     $this->assertNotEmpty($user->email_token);
     // check mail
     $this->assertTrue(MailThief::hasMessageFor($user->email));
     $this->assertEquals('Verification - My Application', MailThief::lastMessage()->subject);
     $emailContent = MailThief::lastMessage()->getBody();
     $this->assertTrue(strpos($emailContent, $user->email_token) !== false);
     // verify
     $this->visit('/register/verify/' . $user->email_token)->see('alert-success');
     // check db
     $this->assertEquals('1', User::first()->verified);
     $this->assertEquals(null, User::first()->email_token);
     // login
     $this->visit('/login')->type($formUser->email, 'email')->type($formUser->password, 'password')->press(trans('user::user.login'))->see('alert-success');
     $this->assertFalse(Auth::guest(), 'User is NOT logged in');
 }
Example #3
0
 /**
  * @test
  */
 public function it_allows_send_a_contact_message()
 {
     MailThief::hijack();
     Honeypot::disable();
     $this->visit(route('contact.show'))->type('John Doe', 'name')->type('*****@*****.**', 'email')->type('Contract', 'subject')->type('PHP Interfaces are important.', 'text')->press('Send')->see(trans('contact::contact.send_successfully'));
     $this->assertTrue(MailThief::hasMessageFor('*****@*****.**'));
     $this->assertEquals('Contract', MailThief::lastMessage()->subject);
     $this->assertEquals('*****@*****.**', MailThief::lastMessage()->data['email']);
 }
 private function getMailer()
 {
     return $this->mailer ?: MailThief::getFacadeRoot();
 }