From 14e77d2885bfe4d3df940e12feb0cce07772b667 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Wed, 3 Dec 2025 21:31:45 +0200 Subject: [PATCH] require full bid data on update --- README.md | 1 - src/Bid/UseCases/UpdateBid.php | 8 ++++---- src/Bid/UseCases/UpdateBidRequest.php | 8 +++++++- tests/Unit/Bid/UseCases/UpdateBidTest.php | 11 +++++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 169074a..b10991e 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # TODO - - Make UpdateBid use case - Make GetBidsOfFreightOrder use case - Dashboard: - Show open requests use case diff --git a/src/Bid/UseCases/UpdateBid.php b/src/Bid/UseCases/UpdateBid.php index a2d2d35..9e70c7e 100644 --- a/src/Bid/UseCases/UpdateBid.php +++ b/src/Bid/UseCases/UpdateBid.php @@ -13,10 +13,10 @@ class UpdateBid public function execute(UpdateBidRequest $dto): void { $bid = $this->bidRepo->find($dto->bidId); - $bid->setCost($dto->data['cost']); - $bid->setIsClosed($dto->data['isClosed']); - $bid->setNotes($dto->data['notes']); - $bid->setFileAttachments($dto->data['fileAttachments']); + $bid->setCost($dto->cost); + $bid->setIsClosed($dto->isClosed); + $bid->setNotes($dto->notes); + $bid->setFileAttachments($dto->fileAttachments); $this->bidRepo->save($bid); } } diff --git a/src/Bid/UseCases/UpdateBidRequest.php b/src/Bid/UseCases/UpdateBidRequest.php index 54d8dae..99d4c18 100644 --- a/src/Bid/UseCases/UpdateBidRequest.php +++ b/src/Bid/UseCases/UpdateBidRequest.php @@ -4,8 +4,14 @@ namespace FreightQuote\Bid\UseCases; class UpdateBidRequest { + /** + * @param string[] $fileAttachments + */ public function __construct( public int $bidId, - public array $data, + public int $cost, + public bool $isClosed, + public string $notes, + public array $fileAttachments, ) {} } diff --git a/tests/Unit/Bid/UseCases/UpdateBidTest.php b/tests/Unit/Bid/UseCases/UpdateBidTest.php index e602a54..1e7f86d 100644 --- a/tests/Unit/Bid/UseCases/UpdateBidTest.php +++ b/tests/Unit/Bid/UseCases/UpdateBidTest.php @@ -19,12 +19,11 @@ class UpdateBidTest extends TestCase $useCase = new UpdateBid($bidRepo); $dto = new UpdateBidRequest( bidId: 0, - data: [ - 'isClosed' => true, - 'cost' => 1, - 'notes' => 'some notes', - 'fileAttachments' => ['/path/to/file'] - ], + isClosed: true, + cost: 1, + notes: 'some notes', + fileAttachments: ['/path/to/file'], + ); $useCase->execute($dto); $bid = $bidRepo->find(0);