public function checkForSingleMailData($message)
 {
     if (StateKeeper::get('expected_body')) {
         $this->assertMessageContains($message, StateKeeper::get('expected_body'));
     }
     if (StateKeeper::get('expected_to')) {
         $this->assertMessageSentTo($message, StateKeeper::get('expected_to'));
     }
     if (StateKeeper::get('expected_subject')) {
         $this->assertMessagSubjectEquals($message, StateKeeper::get('expected_subject'));
     }
 }
 /**
  * @test
  **/
 public function it_send_email_if_user_exists_and_is_not_active_and_set_message()
 {
     $this->enableEmailConfirmation();
     $input = ["email" => "*****@*****.**", "password" => "pass", "activated" => 0, "first_name" => "", "last_name" => ""];
     StateKeeper::set('expected_to', $input["email"]);
     StateKeeper::set('expected_subject', "Registration request to: " . Config::get('laravel-authentication-acl::app_name'));
     StateKeeper::set('expected_body', 'You account has been created. However, before you can use it you need to confirm your email address first by clicking the');
     Input::shouldReceive('all')->once()->andReturn($input)->shouldReceive('getScheme')->shouldReceive('root');
     $this->activateSingleEmailCheck();
     $this->user_repository->create($input);
     $validator = new UserSignupEmailValidator();
     $this->assertFalse($validator->validateEmailUnique("email", $input["email"], $input));
     $this->assertTrue(Session::has('message'));
 }
 /**
  * @test
  **/
 public function it_process_recovery_data_and_redirect_with_success()
 {
     StateKeeper::set('expected_to', $this->current_email);
     StateKeeper::set('expected_subject', 'Password recovery request');
     StateKeeper::set('expected_body', 'We received a request to change your password, if you authorize it');
     Event::listen('mailer.sending', 'Jacopo\\Authentication\\Tests\\Unit\\AuthControllerTest@checkForSingleMailData');
     $this->action('POST', 'Jacopo\\Authentication\\Controllers\\AuthController@postReminder', ["email" => $this->current_email]);
     $this->assertRedirectedTo('/user/reminder-success');
 }
 /**
  * @test
  **/
 public function sendsActivationEmail()
 {
     $this->disableEmailConfirmation();
     $user_email = "*****@*****.**";
     StateKeeper::set('expected_to', $user_email);
     StateKeeper::set('expected_subject', "Registration request to: " . Config::get('laravel-authentication-acl::app_name'));
     StateKeeper::set('expected_body', 'You can now login to the website using the');
     Event::listen('mailer.sending', 'Jacopo\\Authentication\\Tests\\Unit\\AuthControllerTest@checkForSingleMailData');
     $mock_validator = $this->getValidatorSuccess();
     $mock_user_repository = $this->mockUserRepositoryToCreateARandomUser();
     App::instance('user_repository', $mock_user_repository);
     $mock_profile_repository = $this->mockProfileRepositoryCreation();
     App::instance('profile_repository', $mock_profile_repository);
     $mock_auth = $this->mockAuthActiveToken();
     App::instance('authenticator', $mock_auth);
     $service = new UserRegisterService($mock_validator);
     $service->register(["email" => $user_email, "password" => "p", "activated" => 1, "first_name" => "first_name"]);
 }