Files
Investidor-V2/tests/Feature/Auth/RegistrationTest.php
T
Claude 52176edc21
tests / ci (push) Canceled after 0s
Registo: uma recusa do servidor de correio já não dá erro 500
Na produção, a 04/12/2026, o servidor de correio respondeu 550 «User
unknown» e o registo, já gravado, terminou em erro 500. A falha de envio
do email de confirmação passa a ficar registada e o investidor entra no
portal; pode pedir novo envio na página de confirmação.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
2026-12-04 22:27:38 +02:00

58 lines
1.8 KiB
PHP

<?php
namespace Tests\Feature\Auth;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Fortify\Features;
use Tests\TestCase;
class RegistrationTest extends TestCase
{
use RefreshDatabase;
protected function setUp(): void
{
parent::setUp();
$this->skipUnlessFortifyHas(Features::registration());
}
public function test_registration_screen_can_be_rendered()
{
$response = $this->get(route('register'));
$response->assertOk();
}
public function test_new_users_can_register()
{
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'test@example.com',
'password' => 'password',
'password_confirmation' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
}
public function test_a_refused_verification_email_does_not_turn_registration_into_a_server_error()
{
// Production, 04/12/2026: the mail server answered 550 «User unknown» and the
// registration, already saved, ended in HTTP 500.
config(['mail.default' => 'smtp', 'mail.mailers.smtp.host' => '127.0.0.1', 'mail.mailers.smtp.port' => 1, 'mail.mailers.smtp.timeout' => 2]);
$response = $this->post(route('register.store'), [
'name' => 'Test User',
'email' => 'unknown-mailbox@example.com',
'password' => 'password',
'password_confirmation' => 'password',
]);
$this->assertAuthenticated();
$response->assertRedirect(route('dashboard', absolute: false));
$this->assertDatabaseHas('users', ['email' => 'unknown-mailbox@example.com', 'email_verified_at' => null]);
}
}