AspireCloud/tests/Feature/Sanctum/PasswordResetTest.php
Chuck Adams ef6ba4e584
gardening: dependency updates, more tests (#108)
* fix: rm last vestiges of SyncPlugin

* refactor: move Sanctum tests into their own dir

* tests: zap example tests

* test: break helpers out into the tests/Helpers dir

* build: composer bump

* refactor: rm unused TranslationData class

* build: run composer update since bump does not (WTF)

* refactor: move docker app from /var/www/html to /app

this is the de facto standard for docker apps, and it makes config much simpler if we follow it

* build: upgrade dockerfiles to composer 2.8

* build: tweak composer invocation for prod

* tests: rm placeholder that never got filled out

* tests: write tests for sync themes/plugins

* tests: put back dummy unit test because pest freaks out w/ an empty dir

* tests: rm copypasta from SyncThemeTest

* build: bump after update, silly, not before
2024-11-23 09:52:02 -07:00

73 lines
2.1 KiB
PHP

<?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::resetPasswords());
}, '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::resetPasswords());
}, '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 (object $notification) {
$response = $this->get('/reset-password/' . $notification->token);
$response->assertStatus(200);
return true;
});
})->skip(function () {
return !Features::enabled(Features::resetPasswords());
}, '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 (object $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::resetPasswords());
}, 'Password updates are not enabled.');