From 9e2e6d944963357e1aca5781375ead4488a3e395 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Tue, 25 Nov 2025 20:05:29 +0200 Subject: [PATCH] test update bid use case --- src/Bid/Bid.php | 20 +++++++++++++ src/Bid/UseCases/UpdateBid.php | 22 ++++++++++++++ src/Bid/UseCases/UpdateBidRequest.php | 11 +++++++ tests/Unit/Bid/UseCases/UpdateBidTest.php | 36 +++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 src/Bid/UseCases/UpdateBid.php create mode 100644 src/Bid/UseCases/UpdateBidRequest.php create mode 100644 tests/Unit/Bid/UseCases/UpdateBidTest.php diff --git a/src/Bid/Bid.php b/src/Bid/Bid.php index dfdef67..72c9981 100644 --- a/src/Bid/Bid.php +++ b/src/Bid/Bid.php @@ -59,18 +59,38 @@ class Bid return $this->cost; } + public function setCost(int $cost): void + { + $this->cost = $cost; + } + public function getNotes(): ?string { return $this->notes; } + public function setNotes(string $notes): void + { + $this->notes = $notes; + } + public function getFileAttachments(): ?array { return $this->fileAttachments; } + public function setFileAttachments(array $attachments): void + { + $this->fileAttachments = $attachments; + } + public function isClosed(): bool { return $this->isClosed; } + + public function setIsClosed(bool $isClosed): void + { + $this->isClosed = $isClosed; + } } diff --git a/src/Bid/UseCases/UpdateBid.php b/src/Bid/UseCases/UpdateBid.php new file mode 100644 index 0000000..a2d2d35 --- /dev/null +++ b/src/Bid/UseCases/UpdateBid.php @@ -0,0 +1,22 @@ +bidRepo->find($dto->bidId); + $bid->setCost($dto->data['cost']); + $bid->setIsClosed($dto->data['isClosed']); + $bid->setNotes($dto->data['notes']); + $bid->setFileAttachments($dto->data['fileAttachments']); + $this->bidRepo->save($bid); + } +} diff --git a/src/Bid/UseCases/UpdateBidRequest.php b/src/Bid/UseCases/UpdateBidRequest.php new file mode 100644 index 0000000..54d8dae --- /dev/null +++ b/src/Bid/UseCases/UpdateBidRequest.php @@ -0,0 +1,11 @@ +save(new Bid( + 0, 0, 0, false, false, null, null, null + )); + $useCase = new UpdateBid($bidRepo); + $dto = new UpdateBidRequest( + bidId: 0, + data: [ + 'isClosed' => true, + 'cost' => 1, + 'notes' => 'some notes', + 'fileAttachments' => ['/path/to/file'] + ], + ); + $useCase->execute($dto); + $bid = $bidRepo->find(0); + $this->assertEquals(true, $bid->isClosed()); + $this->assertEquals(1, $bid->getCost()); + $this->assertEquals('some notes', $bid->getNotes()); + $this->assertEquals(['/path/to/file'], $bid->getFileAttachments()); + } +}