【发布时间】:2018-10-11 17:05:50
【问题描述】:
我在做注册用户
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')
}
我的注册测试是:
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',
]);
}
我有两个问题:
1) 如何编写一个测试来发送注册邮件并验证它是否可以正常发送和到达?
2) 当用户点击他的电子邮件时,他调用一个传递激活令牌的方法来激活他的帐户
【问题讨论】:
标签: testing laravel-5 phpunit tdd