38 lines
1.4 KiB
PHP
38 lines
1.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Models\Tenant;
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Auth\Notifications\ResetPassword;
|
||
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
|
|
use Illuminate\Support\Facades\Hash;
|
||
|
|
|
||
|
|
uses(DatabaseTransactions::class);
|
||
|
|
|
||
|
|
beforeEach(function () {
|
||
|
|
$this->tenant = Tenant::factory()->create();
|
||
|
|
});
|
||
|
|
|
||
|
|
// FN-RESET (приёмка 22.06.2026): дефолтное Laravel-уведомление ResetPassword
|
||
|
|
// строит URL через route('password.reset'), которого в SPA нет (роут сброса —
|
||
|
|
// /reset/{token}). Без фикса toMail() бросает «Route [password.reset] not defined»,
|
||
|
|
// письмо не уходит. Фикс: ResetPassword::createUrlUsing(...) в AppServiceProvider::boot.
|
||
|
|
test('ResetPassword notification строит ссылку на SPA-роут /reset/{token}?email= без route-error', function () {
|
||
|
|
$user = User::factory()->create([
|
||
|
|
'tenant_id' => $this->tenant->id,
|
||
|
|
'email' => 'reset-link@example.ru',
|
||
|
|
'password_hash' => Hash::make('old-pass-1234'),
|
||
|
|
]);
|
||
|
|
|
||
|
|
$token = 'test-token-abc123';
|
||
|
|
|
||
|
|
// Без фикса этот вызов бросит «Route [password.reset] not defined».
|
||
|
|
$mail = (new ResetPassword($token))->toMail($user);
|
||
|
|
|
||
|
|
$url = (string) $mail->actionUrl;
|
||
|
|
|
||
|
|
expect($url)->toContain('/reset/'.$token);
|
||
|
|
expect($url)->toContain('email='.urlencode('reset-link@example.ru'));
|
||
|
|
});
|