Files
myep-team/tests/Entity/Embeddable/CommunicationTest.php
T

44 lines
1.3 KiB
PHP

<?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']);
}
}