Aplikasi Keuangan yang mengatur lalu lintas transaksi antara bank dan aplikasi internal Kampus
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

38 lines
1.0 KiB

<?php
use App\Domains\Identity\Actions\Passwords\SendPasswordResetLink;
use App\Domains\Identity\DTOs\Passwords\ForgotPasswordDTO;
use App\Domains\Identity\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Password;
uses(Tests\TestCase::class, RefreshDatabase::class);
test('it can send password reset link', function () {
Notification::fake();
$user = User::factory()->create([
'email' => 'test@example.com',
]);
$dto = new ForgotPasswordDTO(
email: 'test@example.com',
);
$action = new SendPasswordResetLink();
$status = $action->execute($dto);
expect($status)->toBe(Password::RESET_LINK_SENT);
});
test('it returns user not found if email does not exist', function () {
$dto = new ForgotPasswordDTO(
email: 'nonexistent@example.com',
);
$action = new SendPasswordResetLink();
$status = $action->execute($dto);
expect($status)->toBe(Password::INVALID_USER);
});