37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
|
|
it('shows the signup page to guests', function () {
|
|
$this->get(route('register'))->assertOk()->assertSee(__('auth.register_title'));
|
|
});
|
|
|
|
it('links between login and signup', function () {
|
|
$this->get(route('login'))->assertOk()->assertSee(route('register'));
|
|
$this->get(route('register'))->assertOk()->assertSee(route('login'));
|
|
});
|
|
|
|
it('registers a new account and signs in', function () {
|
|
$this->post(route('register.store'), [
|
|
'name' => 'New Co',
|
|
'email' => 'new@signup.test',
|
|
'password' => 'password1234',
|
|
'password_confirmation' => 'password1234',
|
|
])->assertRedirect();
|
|
|
|
$user = User::query()->where('email', 'new@signup.test')->first();
|
|
expect($user)->not->toBeNull()->and($user->isOperator())->toBeFalse();
|
|
$this->assertAuthenticatedAs($user);
|
|
});
|
|
|
|
it('rejects a mismatched password confirmation', function () {
|
|
$this->post(route('register.store'), [
|
|
'name' => 'X',
|
|
'email' => 'x@signup.test',
|
|
'password' => 'password1234',
|
|
'password_confirmation' => 'different',
|
|
])->assertSessionHasErrors('password');
|
|
|
|
expect(User::query()->where('email', 'x@signup.test')->exists())->toBeFalse();
|
|
});
|