LoggedOutRouteTest.php
3.48 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
use Tests\BrowserKitTestCase;
use App\Access\Model\User\User;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Event;
use App\Events\Frontend\Auth\UserConfirmed;
use Illuminate\Support\Facades\Notification;
use App\Notifications\Frontend\Auth\UserNeedsConfirmation;
/**
* Class LoggedOutRouteTest.
*/
class LoggedOutRouteTest extends BrowserKitTestCase
{
/**
* User Logged Out Frontend.
*/
/**
* Test the homepage works.
*/
public function testHomePage()
{
$this->visit('/')->assertResponseOk();
}
/**
* Test the macro page works.
*/
public function testMacroPage()
{
$this->visit('/macros')->see('Macro Examples');
}
public function testContactPage()
{
$this->visit('/contact')->see('Contact Us');
}
/**
* Test the login page works.
*/
public function testLoginPage()
{
$this->visit('/login')->see('Login');
}
/**
* Test the register page works.
*/
public function testRegisterPage()
{
$this->visit('/register')->see('Register');
}
/**
* Test the forgot password page works.
*/
public function testForgotPasswordPage()
{
$this->visit('password/reset')->see('Reset Password');
}
/**
* Test the dashboard page redirects to login.
*/
public function testDashboardPageLoggedOut()
{
$this->visit('/dashboard')->seePageIs('/login');
}
/**
* Test the account page redirects to login.
*/
public function testAccountPageLoggedOut()
{
$this->visit('/account')->seePageIs('/login');
}
/**
* Create an unconfirmed user and assure the user gets
* confirmed when hitting the confirmation route.
*/
public function testConfirmAccountRoute()
{
Event::fake();
// Create default user to test with
$unconfirmed = factory(User::class)->states('unconfirmed')->create();
$unconfirmed->attachRole(3); //User
$this->visit('/account/confirm/'.$unconfirmed->confirmation_code)
->seePageIs('/login')
->see('Your account has been successfully confirmed!')
->seeInDatabase(config('access.users_table'), ['email' => $unconfirmed->email, 'confirmed' => 1]);
Event::assertDispatched(UserConfirmed::class);
}
/**
* Assure the user gets resent a confirmation email
* after hitting the resend confirmation route.
*/
public function testResendConfirmAccountRoute()
{
Notification::fake();
$this->visit('/account/confirm/resend/'.$this->user->id)
->seePageIs('/login')
->see('A new confirmation e-mail has been sent to the address on file.');
Notification::assertSentTo([$this->user],
UserNeedsConfirmation::class);
}
/**
* Test the language switcher changes the desired language in the session.
*/
public function testLanguageSwitcher()
{
if (config('locale.status')) {
$this->visit('lang/es')
->see('Registrarse')
->assertSessionHas('locale', 'es');
App::setLocale('en');
}
}
/**
* Test the generic 404 page.
*/
public function test404Page()
{
$response = $this->call('GET', '7g48hwbfw9eufj');
$this->assertEquals(404, $response->getStatusCode());
$this->assertContains('Page Not Found', $response->getContent());
}
}