test that was opened is flipped to true when carrie first sees the bid
This commit is contained in:
parent
b33c6c909a
commit
6dbb92e7b6
2 changed files with 25 additions and 3 deletions
|
|
@ -21,6 +21,10 @@ class GetBidForCarrier
|
||||||
if ($bid === null) {
|
if ($bid === null) {
|
||||||
throw new InvalidArgumentException('Bid not found!');
|
throw new InvalidArgumentException('Bid not found!');
|
||||||
}
|
}
|
||||||
|
if ($bid->getWasOpened() === false) {
|
||||||
|
$bid->setWasOpened(true);
|
||||||
|
$this->bidRepo->save($bid);
|
||||||
|
}
|
||||||
return $bid;
|
return $bid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace Tests\Unit\Bid\UseCases;
|
namespace Tests\Unit\Bid\UseCases;
|
||||||
|
|
||||||
|
use FreightQuote\Bid\Bid;
|
||||||
use FreightQuote\Bid\UseCases\GetBidForCarrier;
|
use FreightQuote\Bid\UseCases\GetBidForCarrier;
|
||||||
use FreightQuote\Bid\UseCases\GetBidForCarrierRequest;
|
use FreightQuote\Bid\UseCases\GetBidForCarrierRequest;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
@ -10,13 +11,30 @@ use Tests\Fakes\Bid\FakeBidRepository;
|
||||||
|
|
||||||
class GetBidForCarrierTest extends TestCase
|
class GetBidForCarrierTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private FakeBidRepository $bidRepo;
|
||||||
|
private GetBidForCarrier $useCase;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$this->bidRepo = new FakeBidRepository();
|
||||||
|
$this->useCase = new GetBidForCarrier($this->bidRepo);
|
||||||
|
}
|
||||||
|
|
||||||
public function test_nonexistant_bid_throws_error(): void
|
public function test_nonexistant_bid_throws_error(): void
|
||||||
{
|
{
|
||||||
$this->expectException(InvalidArgumentException::class);
|
$this->expectException(InvalidArgumentException::class);
|
||||||
$bidId = '12345abcd';
|
$bidId = '12345abcd';
|
||||||
$dto = new GetBidForCarrierRequest($bidId);
|
$dto = new GetBidForCarrierRequest($bidId);
|
||||||
$bidRepo = new FakeBidRepository();
|
$foundBid = $this->useCase->execute($dto);
|
||||||
$useCase = new GetBidForCarrier($bidRepo);
|
}
|
||||||
$foundBid = $useCase->execute($dto);
|
|
||||||
|
public function test_first_view_flips_opened_flag(): void
|
||||||
|
{
|
||||||
|
$bidId = 'abcd';
|
||||||
|
$this->bidRepo->save(new Bid($bidId, 0, 0, false));
|
||||||
|
$foundBid = $this->useCase->execute(
|
||||||
|
new GetBidForCarrierRequest($bidId)
|
||||||
|
);
|
||||||
|
$this->assertEquals(true, $foundBid->getWasOpened());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue