Skip to content

Commit

Permalink
fix: remove transport manager address optimistic lock (dvsa/olcs-back…
Browse files Browse the repository at this point in the history
…end#149)

* fix: Allow removal of transport manager address

* fix: Test fix

* fix: Unit tests
  • Loading branch information
wadedvsa authored Apr 22, 2024
1 parent dfa8c54 commit 27ece8a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ private function maybeDeleteContactDetailsAndAddress($contactDetails)
$this->injectRepos();
if ($contactDetails->getAddress() !== null) {
$addressRepo = $this->getRepo('Address');
$addressRepo->delete($contactDetails->getAddress());
$address = $contactDetails->getAddress();
$addressRepo->refresh($address);
$addressRepo->delete($address);
}
$this->getRepo('ContactDetails')->delete($contactDetails);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,12 @@ public function testHandleExistingCorrespondenceUpdateWithNoChangeAndDeletedTran
)
->getMock();

$this->repoMap['Address']->shouldReceive('delete')->with($transportConsultantAddress);
$this->repoMap['Address']->shouldReceive('delete')
->once()
->with($transportConsultantAddress);
$this->repoMap['Address']->shouldReceive('refresh')
->once()
->with($transportConsultantAddress);
$result = $this->sut->handleCommand($command);

$expected = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public function testMaybeDeleteContactDetailsAndAddressWithCdNull()
public function testMaybeDeleteContactDetailsAndAddress()
{
$address = m::mock(AddressEntity::class);
$this->repoMap['Address']->shouldReceive('delete')->with($address);
$this->repoMap['Address']->shouldReceive('delete')
->once()
->with($address);
$this->repoMap['Address']->shouldReceive('refresh')
->once()
->with($address);
$contactDetails = m::mock(ContactDetailsEntity::class);
$contactDetails->shouldReceive('getAddress')->andReturn($address);
$this->repoMap['ContactDetails']->shouldReceive('delete')->with($contactDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ public function testHandleCommand()
$workshopEntity1->shouldReceive('getContactDetails')->andReturn($contactDetails1);
$workshopEntity2 = m::mock(WorkshopEntity::class);
$workshopEntity2->shouldReceive('getContactDetails')->andReturn(null);
$this->repoMap['Address']->shouldReceive('delete')->with($address1);
$this->repoMap['Address']->shouldReceive('delete')
->once()
->with($address1);
$this->repoMap['Address']->shouldReceive('refresh')
->once()
->with($address1);
$this->repoMap['ContactDetails']->shouldReceive('delete')->with($contactDetails1);

$this->repoMap['Workshop']->shouldReceive('fetchById')
Expand Down

0 comments on commit 27ece8a

Please sign in to comment.