remove references of carrier and freight order ids from each other
They reference each other in created bid so these arrays are not necessary
This commit is contained in:
parent
e79064d909
commit
948380ba9f
6 changed files with 0 additions and 69 deletions
|
|
@ -16,7 +16,6 @@ class Carrier
|
|||
private string $notes,
|
||||
private string $loadProfile,
|
||||
private array $countriesServing,
|
||||
private array $freightOrderIds,
|
||||
) {}
|
||||
|
||||
public function getId(): ?int
|
||||
|
|
@ -63,14 +62,4 @@ class Carrier
|
|||
{
|
||||
return $this->countriesServing;
|
||||
}
|
||||
|
||||
public function getFreightOrderIds(): array
|
||||
{
|
||||
return $this->freightOrderIds;
|
||||
}
|
||||
|
||||
public function setFreightOrderIds(array $ids): void
|
||||
{
|
||||
$this->freightOrderIds = $ids;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ class FreightOrder
|
|||
private string $loadDetails,
|
||||
private string $notes,
|
||||
private array $fileAttachments,
|
||||
private array $carrierIds,
|
||||
) {}
|
||||
|
||||
public function getId(): ?int
|
||||
|
|
@ -66,9 +65,4 @@ class FreightOrder
|
|||
{
|
||||
return $this->fileAttachments;
|
||||
}
|
||||
|
||||
public function getCarrierIds(): array
|
||||
{
|
||||
return $this->carrierIds;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ class CreateFreightOrder
|
|||
foreach ($carrierIds as $carrierId) {
|
||||
$carrier = $this->carrierRepo->find($carrierId);
|
||||
$freightOrderId = $freightOrder->getId();
|
||||
$this->updateCarrierOrderIds($carrier, $freightOrderId);
|
||||
$this->sendEmail($carrier->getEmail(), $freightOrder);
|
||||
$bidsCreated[] = $this->createBid(
|
||||
$freightOrderId,
|
||||
|
|
@ -83,16 +82,6 @@ class CreateFreightOrder
|
|||
$this->emailer->send($email);
|
||||
}
|
||||
|
||||
private function updateCarrierOrderIds(
|
||||
Carrier $carrier,
|
||||
int $freightOrderId
|
||||
): void {
|
||||
$carrierFreightOrderIds = $carrier->getFreightOrderIds();
|
||||
$carrierFreightOrderIds[] = $freightOrderId;
|
||||
$carrier->setFreightOrderIds($carrierFreightOrderIds);
|
||||
$this->carrierRepo->save($carrier);
|
||||
}
|
||||
|
||||
private function saveFreightOrder(
|
||||
CreateFreightOrderRequestDTO $dto,
|
||||
): FreightOrder {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ class FakeCarrierRepository implements CarrierRepository
|
|||
$carrier->getNotes(),
|
||||
$carrier->getLoadProfile(),
|
||||
$carrier->getCountriesServing(),
|
||||
$carrier->getFreightOrderIds(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -51,7 +50,6 @@ class FakeCarrierRepository implements CarrierRepository
|
|||
$carrier->getNotes(),
|
||||
$carrier->getLoadProfile(),
|
||||
$carrier->getCountriesServing(),
|
||||
$carrier->getFreightOrderIds(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +70,6 @@ class FakeCarrierRepository implements CarrierRepository
|
|||
$carrier->getNotes(),
|
||||
$carrier->getLoadProfile(),
|
||||
$carrier->getCountriesServing(),
|
||||
$carrier->getFreightOrderIds(),
|
||||
);
|
||||
}, $this->existingCarriers);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ class FakeFreightOrderRepository implements FreightOrderRepository
|
|||
$freightOrder->getLoadDetails(),
|
||||
$freightOrder->getNotes(),
|
||||
$freightOrder->getFileAttachments(),
|
||||
$freightOrder->getCarrierIds(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,7 +49,6 @@ class FakeFreightOrderRepository implements FreightOrderRepository
|
|||
$freightOrder->getLoadDetails(),
|
||||
$freightOrder->getNotes(),
|
||||
$freightOrder->getFileAttachments(),
|
||||
$freightOrder->getCarrierIds(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,40 +60,6 @@ class CreateFreightOrderTest extends TestCase
|
|||
$this->assertEquals($dto->loadDetails, $foundFreightOrder->getLoadDetails());
|
||||
$this->assertEquals($dto->notes, $foundFreightOrder->getNotes());
|
||||
$this->assertEquals($dto->fileAttachments, $foundFreightOrder->getFileAttachments());
|
||||
$this->assertEquals($dto->carrierIds, $foundFreightOrder->getCarrierIds());
|
||||
}
|
||||
|
||||
public function test_carrier_is_connected_to_order(): void
|
||||
{
|
||||
$carrierId = 0;
|
||||
$this->carrierRepo->save(new Carrier(
|
||||
id: $carrierId,
|
||||
email: 'test@email.com',
|
||||
companyName: 'company name',
|
||||
contactPerson: 'person',
|
||||
phoneNumber: '123456798',
|
||||
notes: 'some notes',
|
||||
loadProfile: 'LTL/FTL',
|
||||
countriesServing: ['USA'],
|
||||
freightOrderIds: [],
|
||||
));
|
||||
$dto = new CreateFreightOrderRequestDTO(
|
||||
shipFrom: 'ny',
|
||||
shipTo: 'nj',
|
||||
pickupDate: new DateTime('+5 days'),
|
||||
deliveryDeadline: new DateTime('+10 days'),
|
||||
loadDetails: 'some details',
|
||||
notes: 'some notes',
|
||||
fileAttachments: ['path/to/file', 'another/path/file'],
|
||||
carrierIds: [$carrierId],
|
||||
);
|
||||
$response = $this->useCase->execute($dto);
|
||||
$createdFreightOrder = $response->freightOrder;
|
||||
$foundCarrier = $this->carrierRepo->find($carrierId);
|
||||
$this->assertEquals(
|
||||
[$createdFreightOrder->getId()],
|
||||
$foundCarrier->getFreightOrderIds()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_email_is_sent(): void
|
||||
|
|
@ -108,7 +74,6 @@ class CreateFreightOrderTest extends TestCase
|
|||
notes: 'some notes',
|
||||
loadProfile: 'LTL/FTL',
|
||||
countriesServing: ['USA'],
|
||||
freightOrderIds: [],
|
||||
));
|
||||
$dto = new CreateFreightOrderRequestDTO(
|
||||
shipFrom: 'ny',
|
||||
|
|
@ -136,7 +101,6 @@ class CreateFreightOrderTest extends TestCase
|
|||
notes: 'some notes',
|
||||
loadProfile: 'LTL/FTL',
|
||||
countriesServing: ['USA'],
|
||||
freightOrderIds: [],
|
||||
));
|
||||
$dto = new CreateFreightOrderRequestDTO(
|
||||
shipFrom: 'ny',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue