-
Notifications
You must be signed in to change notification settings - Fork 308
/
Copy pathEmailVerificationNotificationControllerTest.php
55 lines (41 loc) · 1.9 KB
/
EmailVerificationNotificationControllerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace Laravel\Fortify\Tests;
use Illuminate\Contracts\Auth\Authenticatable;
use Mockery;
class EmailVerificationNotificationControllerTest extends OrchestraTestCase
{
public function test_email_verification_notification_can_be_sent()
{
$user = Mockery::mock(Authenticatable::class);
$user->shouldReceive('hasVerifiedEmail')->andReturn(false);
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
$user->shouldReceive('sendEmailVerificationNotification')->once();
$response = $this->from('/email/verify')
->actingAs($user)
->post('/email/verification-notification');
$response->assertRedirect('/email/verify');
}
public function test_user_is_redirect_if_already_verified()
{
$user = Mockery::mock(Authenticatable::class);
$user->shouldReceive('hasVerifiedEmail')->andReturn(true);
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
$user->shouldReceive('sendEmailVerificationNotification')->never();
$response = $this->from('/email/verify')
->actingAs($user)
->post('/email/verification-notification');
$response->assertRedirect('/home');
}
public function test_user_is_redirect_to_intended_url_if_already_verified()
{
$user = Mockery::mock(Authenticatable::class);
$user->shouldReceive('hasVerifiedEmail')->andReturn(true);
$user->shouldReceive('getAuthIdentifier')->andReturn(1);
$user->shouldReceive('sendEmailVerificationNotification')->never();
$response = $this->from('/email/verify')
->actingAs($user)
->withSession(['url.intended' => 'http://foo.com/bar'])
->post('/email/verification-notification');
$response->assertRedirect('http://foo.com/bar');
}
}