mardi 1 mai 2018

Send email with TDD Laravel 5.6

I am doing the registration user

public function register(RegistrationUser $request)
{
  $user = $this->usersRepo->create($request->all());

  $user->activation_token = str_random(48);
  $user->save();

  Mail::to($user->email)->queue(new ActivationAccount($user->first_name, $user->last_name, $user->email, $request->input('password'), $url));

  return redirect()->route('successful.registration')

}

My registration test is:

 public function it_creates_a_new_user()
{

    $this->withExceptionHandling();

    $response = $this->get(route('register'))
        ->assertStatus(200);

    $this->post('register', [
        'first_name' => 'Juan',
        'last_name' => 'Lopez',            
        'email' => 'jlopez@gmail.com',
        'password' => 'secret',
        'activation_tone' => str_random(48)
    ])->assertRedirect(route('successful.registration'));

    $this->assertDatabaseHas('users', [
        'email' => 'jlopez@gmail.com',
    ]);

  }

I have two questions:

1) How can I write a test to send the registration email and verify that it sends and arrives well?

2) When the user clicks on his email he calls a method where the activation token is passed to activate his account



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2riZAJN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire