Files
portal/app/tests/Feature/Auth/ConfirmSetsEmailVerifiedAtTest.php
T
Дмитрий 88ace4e3d9
Accessibility (Pa11y live) / a11y (push) Has been cancelled
test: дозакрытие оздоровления — protekateli pd-аудита, видимость supplier, новый флоу регистрации
Снижение остатка 19 to 5. Всё тест-сторона:
- PdErasureServiceTest + AdminPdSubjectRequestsControllerTest: SharesSupplierPdo —
  перестали коммитить pd_processing_log через pgsql_supplier, что ломало
  глобальный audit:verify-chains (6 падений) и амплифицировало PhoneRegionSmoke.
- ReportFileDeletePdLogTest: SharesSupplierPdo — cron reports:cleanup-expired
  теперь видит незакоммиченные job'ы теста.
- AdminSuppliersControllerTest: устойчивый ассерт (с фазы 3 в suppliers есть direct).
- AuthLogCoverageTest/AuthFlowIntegrationTest: новый флоу самозаписи G1/SP1 —
  register_success пишется после confirm-email; добавлен шаг подтверждения.
- ImpersonationTest end: verify (G7-B) ставит маркер impersonation → admin-зона
  закрыта by design; помечаем токен used напрямую вместо session-takeover.
- CleanupInactiveSupplierProjectsJobTest: phase A читает pivot project_supplier_links —
  добавлена привязка linkProjectToSupplier (раньше был только legacy FK).
- Pint-нормализация uses() FQN to import в ранее тронутых файлах.

Остаток 5 (НЕ слепой патч): webhook B-префикс ×2 (решение владельца), advisory-lock
audit-цепочки (возможный дрейф схемы, флажок), SupplierConnection WARN#2 (cap-3,
поведенческое), SupplierPortalClientTest (пре-существующий, не от этих правок).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 08:19:53 +03:00

57 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Models\EmailVerification;
use App\Models\Tenant;
use App\Models\User;
use App\Services\Auth\RegistrationService;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
use Tests\Concerns\SharesSupplierPdo;
uses(DatabaseTransactions::class);
uses(SharesSupplierPdo::class);
// FN-3 (приёмка 22.06.2026): онбординг-confirm активировал владельца, но НЕ ставил
// users.email_verified_at — поле оставалось NULL, хотя email фактически подтверждён
// кодом из письма. Контракт: успешный confirm проставляет email_verified_at.
//
// confirm() работает через BYPASSRLS-соединение pgsql_supplier; создаём фикстуры на
// нём же (одна видимость) внутри собственной транзакции с rollback — без утечки в БД.
test('RegistrationService::confirm проставляет users.email_verified_at', function () {
$conn = DB::connection('pgsql_supplier');
$conn->beginTransaction();
try {
$tenant = Tenant::on('pgsql_supplier')->create(Tenant::factory()->raw());
$user = User::on('pgsql_supplier')->create(User::factory()->raw([
'tenant_id' => $tenant->id,
'email' => 'confirm-verified@example.ru',
'password_hash' => Hash::make('start-pass-1234'),
'is_active' => false,
'email_verified_at' => null,
]));
EmailVerification::on('pgsql_supplier')->create([
'user_id' => $user->id,
'email' => 'confirm-verified@example.ru',
'token' => (string) Str::uuid(),
'code_hash' => Hash::make('123456'),
'failed_attempts' => 0,
'expires_at' => now()->addMinutes(10),
'verified_at' => null,
]);
app(RegistrationService::class)->confirm('confirm-verified@example.ru', '123456');
$fresh = User::on('pgsql_supplier')->find($user->id);
expect($fresh->is_active)->toBeTrue();
expect($fresh->email_verified_at)->not->toBeNull();
} finally {
$conn->rollBack();
}
});