test that carrier email is unique

This commit is contained in:
Yisroel Baum 2025-11-18 09:22:13 +02:00
parent 908baee2a7
commit 2d8bca1a07
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
4 changed files with 60 additions and 0 deletions

View file

@ -3,6 +3,7 @@
namespace Tests\Unit\Carrier\UseCases;
use PHPUnit\Framework\TestCase;
use InvalidArgumentException;
use Tests\Fakes\Carrier\FakeCarrierRepository;
use FreightQuote\Carrier\UseCases\CreateCarrier;
use FreightQuote\Carrier\UseCases\CreateCarrierRequest;
@ -39,4 +40,38 @@ class CreateCarrierTest extends TestCase
$this->assertEquals($loadProfile, $foundCarrier->getLoadProfile());
$this->assertEquals($countriesServing, $foundCarrier->getCountriesServing());
}
public function test_email_is_unique(): void
{
$this->expectException(InvalidArgumentException::class);
$email = 'joe@shmoe.com';
$company = 'test company';
$contactPerson = 'Joe Shmoe';
$phoneNumber = '132456798';
$notes = 'some notes';
$loadProfile = 'LTL/FTL'; // Less than full trailer load and full trailer load
$countriesServing = ['USA', 'FRA', 'UK'];
$carrierRepo = new FakeCarrierRepository();
$dto1 = new CreateCarrierRequest(
$email,
$company,
$contactPerson,
$phoneNumber,
$notes,
$loadProfile,
$countriesServing,
);
$dto2 = new CreateCarrierRequest(
$email,
$company,
$contactPerson,
$phoneNumber,
$notes,
$loadProfile,
$countriesServing,
);
$useCase = new CreateCarrier($carrierRepo);
$useCase->execute($dto1);
$useCase->execute($dto2);
}
}