forked from dwightwatson/laravel-auth-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegisterTest.php
68 lines (55 loc) · 1.47 KB
/
RegisterTest.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
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Tests\Feature;
use App\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class RegisterTest extends TestCase
{
use DatabaseTransactions;
/**
* The registration form can be displayed.
*
* @return void
*/
public function testRegisterFormDisplayed()
{
$response = $this->get('/register');
$response->assertStatus(200);
}
/**
* A valid user can be registered.
*
* @return void
*/
public function testRegistersAValidUser()
{
$user = factory(User::class)->make();
$response = $this->post('register', [
'name' => $user->name,
'email' => $user->email,
'password' => 'secret',
'password_confirmation' => 'secret'
]);
$response->assertStatus(302);
$this->assertAuthenticated();
}
/**
* An invalid user is not registered.
*
* @return void
*/
public function testDoesNotRegisterAnInvalidUser()
{
$user = factory(User::class)->make();
$response = $this->post('register', [
'name' => $user->name,
'email' => $user->email,
'password' => 'secret',
'password_confirmation' => 'invalid'
]);
$response->assertSessionHasErrors();
$this->assertGuest();
}
}