move dto from constructor to method paramour
in create carrier use case
This commit is contained in:
parent
18e43b3bac
commit
908baee2a7
2 changed files with 10 additions and 11 deletions
|
|
@ -8,21 +8,20 @@ use FreightQuote\Carrier\CarrierRepository;
|
||||||
class CreateCarrier
|
class CreateCarrier
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private CreateCarrierRequest $dto,
|
|
||||||
private CarrierRepository $carrierRepo,
|
private CarrierRepository $carrierRepo,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function execute(): Carrier
|
public function execute(CreateCarrierRequest $dto): Carrier
|
||||||
{
|
{
|
||||||
$carrier = new Carrier(
|
$carrier = new Carrier(
|
||||||
null,
|
null,
|
||||||
$this->dto->email,
|
$dto->email,
|
||||||
$this->dto->companyName,
|
$dto->companyName,
|
||||||
$this->dto->contactPerson,
|
$dto->contactPerson,
|
||||||
$this->dto->phoneNumber,
|
$dto->phoneNumber,
|
||||||
$this->dto->notes,
|
$dto->notes,
|
||||||
$this->dto->loadProfile,
|
$dto->loadProfile,
|
||||||
$this->dto->countriesServing,
|
$dto->countriesServing,
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,8 @@ class CreateCarrierTest extends TestCase
|
||||||
$loadProfile,
|
$loadProfile,
|
||||||
$countriesServing,
|
$countriesServing,
|
||||||
);
|
);
|
||||||
$useCase = new CreateCarrier($dto, $carrierRepo);
|
$useCase = new CreateCarrier($carrierRepo);
|
||||||
$response = $useCase->execute();
|
$response = $useCase->execute($dto);
|
||||||
$foundCarrier = $carrierRepo->find($response->getId());
|
$foundCarrier = $carrierRepo->find($response->getId());
|
||||||
$this->assertEquals($email, $foundCarrier->getEmail());
|
$this->assertEquals($email, $foundCarrier->getEmail());
|
||||||
$this->assertEquals($company, $foundCarrier->getCompanyName());
|
$this->assertEquals($company, $foundCarrier->getCompanyName());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue