-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds full Pest support using the `--pest` option * Removes non needed underscores * Removes non needed underscores * Adds missing examples * Moves inertia pest tests to expectation API * Moves tests to expectation API * Fixes * Uses `->skip` method * Fix * Removes extra semicolons * Refactor * Refactor * Refactor * CS * CS * Removes non needed underscores * Wording Co-authored-by: Nuno Maduro <[email protected]>
- Loading branch information
1 parent
589a6f3
commit dd45c1a
Showing
39 changed files
with
1,262 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use App\Models\User; | ||
use App\Providers\RouteServiceProvider; | ||
|
||
test('login screen can be rendered', function () { | ||
$response = $this->get('/login'); | ||
|
||
$response->assertStatus(200); | ||
}); | ||
|
||
test('users can authenticate using the login screen', function () { | ||
$user = User::factory()->create(); | ||
|
||
$response = $this->post('/login', [ | ||
'email' => $user->email, | ||
'password' => 'password', | ||
]); | ||
|
||
$this->assertAuthenticated(); | ||
$response->assertRedirect(RouteServiceProvider::HOME); | ||
}); | ||
|
||
test('users can not authenticate with invalid_password', function () { | ||
$user = User::factory()->create(); | ||
|
||
$this->post('/login', [ | ||
'email' => $user->email, | ||
'password' => 'wrong-password', | ||
]); | ||
|
||
$this->assertGuest(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
use App\Models\User; | ||
use App\Providers\RouteServiceProvider; | ||
use Illuminate\Auth\Events\Verified; | ||
use Illuminate\Support\Facades\Event; | ||
use Illuminate\Support\Facades\URL; | ||
use Laravel\Fortify\Features; | ||
|
||
test('email verification screen can be rendered', function () { | ||
$user = User::factory()->withPersonalTeam()->create([ | ||
'email_verified_at' => null, | ||
]); | ||
|
||
$response = $this->actingAs($user)->get('/email/verify'); | ||
|
||
$response->assertStatus(200); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::emailVerification()); | ||
}, 'Email verification not enabled.'); | ||
|
||
test('email can be verified', function () { | ||
Event::fake(); | ||
|
||
$user = User::factory()->create([ | ||
'email_verified_at' => null, | ||
]); | ||
|
||
$verificationUrl = URL::temporarySignedRoute( | ||
'verification.verify', | ||
now()->addMinutes(60), | ||
['id' => $user->id, 'hash' => sha1($user->email)] | ||
); | ||
|
||
$response = $this->actingAs($user)->get($verificationUrl); | ||
|
||
Event::assertDispatched(Verified::class); | ||
|
||
expect($user->fresh()->hasVerifiedEmail())->toBeTrue(); | ||
$response->assertRedirect(RouteServiceProvider::HOME.'?verified=1'); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::emailVerification()); | ||
}, 'Email verification not enabled.'); | ||
|
||
test('email can not verified with invalid hash', function () { | ||
$user = User::factory()->create([ | ||
'email_verified_at' => null, | ||
]); | ||
|
||
$verificationUrl = URL::temporarySignedRoute( | ||
'verification.verify', | ||
now()->addMinutes(60), | ||
['id' => $user->id, 'hash' => sha1('wrong-email')] | ||
); | ||
|
||
$this->actingAs($user)->get($verificationUrl); | ||
|
||
expect($user->fresh()->hasVerifiedEmail())->toBeFalse(); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::emailVerification()); | ||
}, 'Email verification not enabled.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
test('example', function () { | ||
$response = $this->get('/'); | ||
|
||
$response->assertStatus(200); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
test('example', function () { | ||
expect(true)->toBeTrue(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use App\Models\User; | ||
use Laravel\Jetstream\Features; | ||
|
||
test('confirm password screen can be rendered', function () { | ||
$user = Features::hasTeamFeatures() | ||
? User::factory()->withPersonalTeam()->create() | ||
: User::factory()->create(); | ||
|
||
$response = $this->actingAs($user)->get('/user/confirm-password'); | ||
|
||
$response->assertStatus(200); | ||
}); | ||
|
||
test('password can be confirmed', function () { | ||
$user = User::factory()->create(); | ||
|
||
$response = $this->actingAs($user)->post('/user/confirm-password', [ | ||
'password' => 'password', | ||
]); | ||
|
||
$response->assertRedirect(); | ||
$response->assertSessionHasNoErrors(); | ||
}); | ||
|
||
test('password is not confirmed with invalid password', function () { | ||
$user = User::factory()->create(); | ||
|
||
$response = $this->actingAs($user)->post('/user/confirm-password', [ | ||
'password' => 'wrong-password', | ||
]); | ||
|
||
$response->assertSessionHasErrors(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
use App\Models\User; | ||
use Illuminate\Auth\Notifications\ResetPassword; | ||
use Illuminate\Support\Facades\Notification; | ||
use Laravel\Fortify\Features; | ||
|
||
test('reset password link screen can be rendered', function () { | ||
$response = $this->get('/forgot-password'); | ||
|
||
$response->assertStatus(200); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::updatePasswords()); | ||
}, 'Password updates are not enabled.'); | ||
|
||
test('reset password link can be requested', function () { | ||
Notification::fake(); | ||
|
||
$user = User::factory()->create(); | ||
|
||
$response = $this->post('/forgot-password', [ | ||
'email' => $user->email, | ||
]); | ||
|
||
Notification::assertSentTo($user, ResetPassword::class); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::updatePasswords()); | ||
}, 'Password updates are not enabled.'); | ||
|
||
test('reset password screen can be rendered', function () { | ||
Notification::fake(); | ||
|
||
$user = User::factory()->create(); | ||
|
||
$response = $this->post('/forgot-password', [ | ||
'email' => $user->email, | ||
]); | ||
|
||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) { | ||
$response = $this->get('/reset-password/'.$notification->token); | ||
|
||
$response->assertStatus(200); | ||
|
||
return true; | ||
}); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::updatePasswords()); | ||
}, 'Password updates are not enabled.'); | ||
|
||
test('password can be reset with valid token', function () { | ||
Notification::fake(); | ||
|
||
$user = User::factory()->create(); | ||
|
||
$response = $this->post('/forgot-password', [ | ||
'email' => $user->email, | ||
]); | ||
|
||
Notification::assertSentTo($user, ResetPassword::class, function ($notification) use ($user) { | ||
$response = $this->post('/reset-password', [ | ||
'token' => $notification->token, | ||
'email' => $user->email, | ||
'password' => 'password', | ||
'password_confirmation' => 'password', | ||
]); | ||
|
||
$response->assertSessionHasNoErrors(); | ||
|
||
return true; | ||
}); | ||
})->skip(function () { | ||
return ! Features::enabled(Features::updatePasswords()); | ||
}, 'Password updates are not enabled.'); |
Oops, something went wrong.