feat: normalize email addresses to lowercase on write

This commit is contained in:
2026-09-21 12:20:55 +02:00
parent d6327f033e
commit af46c57bd1
7 changed files with 102 additions and 4 deletions
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace App\Tests\Entity\Embeddable;
use App\Entity\Embeddable\Communication;
use PHPUnit\Framework\TestCase;
/**
* Pins the lowercasing of the teamer's contact address. This is the address the profile form
* writes and the one toPayload() pushes back to BusPro, so a mixed-case value entered here
* would otherwise diverge from the login identity stored in User::email.
*/
class CommunicationTest extends TestCase
{
public function testSetEmailNormalizesCaseAndSurroundingWhitespace(): void
{
$communication = (new Communication())->setEmail(' [email protected] ');
$this->assertSame('[email protected]', $communication->getEmail());
}
public function testSetEmailKeepsNull(): void
{
$communication = (new Communication())->setEmail(null);
$this->assertNull($communication->getEmail());
}
/**
* The outbound BusPro payload must carry the normalized form, not the raw input.
*/
public function testPayloadCarriesTheNormalizedAddress(): void
{
$communication = (new Communication())
->setEmail('[email protected]')
->setMobile('0170 1234567')
;
$this->assertSame('[email protected]', $communication->toPayload()['email']);
}
}