Skip to content

Commit

Permalink
UML-3622 rework trust corporations (#2854)
Browse files Browse the repository at this point in the history
* UML-3619 wip

* UML-3619 wip

* UML-3619 wip

* UML-3619 Convert incoming LPAs to combined format (repository layer)

* UML-3619 updated tests and added donotserialize on func

* UML-3619 updated tests

* UML-3619 updated tests for codecoverage

* UML-3619 updated lint

* UML-3619 updated tests and added test case on hydrating sirius & lpa store

* UML-3619 updated tests and added test case on serialising sirius & lpa store

* implement the interface

* trust corporations, tests

* fixes

* fixes

---------

Co-authored-by: Allen Annom <[email protected]>
  • Loading branch information
nickdavis2001 and allenannom authored Oct 8, 2024
1 parent 85cb046 commit 8e753df
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
use App\Entity\Casters\ExtractCountryFromLpaStore;
use App\Entity\Casters\ExtractTownFromLpaStore;
use App\Entity\Person;
use App\Service\Lpa\GetTrustCorporationStatus\TrustCorporationStatusInterface;
use DateTimeImmutable;
use EventSauce\ObjectHydrator\DoNotSerialize;
use EventSauce\ObjectHydrator\MapFrom;

class LpaStoreTrustCorporations extends Person
class LpaStoreTrustCorporations extends Person implements TrustCorporationStatusInterface
{
public function __construct(
#[MapFrom('address')]
Expand Down Expand Up @@ -68,4 +70,22 @@ public function companyName(): ?string
{
return $this->companyName;
}

#[DoNotSerialize]
public function getCompanyName(): string
{
return $this->companyName();
}

#[DoNotSerialize]
public function getSystemStatus(): bool|string
{
return $this->systemStatus;
}

#[DoNotSerialize]
public function getUid(): string
{
return $this->uId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Entity\Sirius;

use App\Entity\Person;
use App\Service\Lpa\GetTrustCorporationStatus\TrustCorporationStatusInterface;
use EventSauce\ObjectHydrator\DoNotSerialize;
use App\Entity\Sirius\Casters\{
ExtractAddressLine1FromSiriusLpa,
Expand All @@ -21,7 +22,7 @@
use DateTimeImmutable;
use JsonSerializable;

class SiriusLpaTrustCorporations extends Person implements JsonSerializable
class SiriusLpaTrustCorporations extends Person implements JsonSerializable , TrustCorporationStatusInterface
{
public function __construct(
#[MapFrom('addresses')]
Expand Down Expand Up @@ -95,4 +96,22 @@ public function jsonSerialize(): mixed

return $data;
}

#[DoNotSerialize]
public function getCompanyName(): ?string
{
return $this->name;
}

#[DoNotSerialize]
public function getSystemStatus(): bool|string
{
return $this->systemStatus;
}

#[DoNotSerialize]
public function getUid(): string
{
return $this->uId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function __invoke(TrustCorporationStatusInterface $trustCorporation): int
return TrustCorporationStatuses::GHOST_TC->value;
}

if (!$trustCorporation->getSystemStatus()) {
$systemStatus = $trustCorporation->getSystemStatus();
if (!$systemStatus || $systemStatus === 'false') {
$this->logger->debug('Looked up attorney {id} but is inactive', ['id' => $trustCorporation->getUid()]);
return TrustCorporationStatuses::INACTIVE_TC->value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

interface TrustCorporationStatusInterface
{
public function getCompanyName(): string;
public function getCompanyName(): ?string;

public function getSystemStatus(): bool;
public function getSystemStatus(): bool|string;

public function getUid(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace AppTest\Service\Lpa;

use App\Entity\LpaStore\LpaStoreTrustCorporations;
use App\Entity\Sirius\SiriusLpaTrustCorporations;
use App\Service\Lpa\GetTrustCorporationStatus;
use App\Service\Lpa\SiriusPerson;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -26,6 +28,7 @@ public function setUp(): void
#[Test]
public function returns_0_if_trustCorporation_is_active(): void
{

$trustCorporation = new SiriusPerson(
[
'uId' => 7,
Expand All @@ -41,6 +44,36 @@ public function returns_0_if_trustCorporation_is_active(): void
$this->assertEquals(0, ($status)($trustCorporation));
}

#[Test]
public function returns_0_if_trustCorporation_is_active_combined_format_lpastore(): void
{
$trustCorporation = new LpaStoreTrustCorporations(
$addressLine1 = '103 Line 1',
$addressLine2 = null,
$addressLine3 = null,
$countryName = 'UK',
$country = 'GB',
$county = null,
$dob = null,
$email = null,
$firstname = null,
$firstnames = null,
$name = 'ABC Ltd',
$otherNames = null,
$postcode = null,
$surname = null,
$systemStatus = 'active',
$town = 'Town',
$type = null,
$uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(0, ($status)($trustCorporation));
}
#[Test]
public function returns_1_if_trustCorporation_is_a_ghost(): void
{
Expand All @@ -58,6 +91,36 @@ public function returns_1_if_trustCorporation_is_a_ghost(): void

$this->assertEquals(1, ($status)($trustCorporation));
}
#[Test]
public function returns_1_if_trustCorporation_is_a_ghost_combined_format_lpastore(): void
{
$trustCorporation = new LpaStoreTrustCorporations(
$addressLine1 = '103 Line 1',
$addressLine2 = null,
$addressLine3 = null,
$companyName = '',
$country = 'GB',
$county = null,
$dob = null,
$email = null,
$firstname = null,
$firstnames = null,
$name = '',
$otherNames = null,
$postcode = null,
$surname = null,
$systemStatus = 'active',
$town = 'Town',
$type = null,
$uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(1, ($status)($trustCorporation));
}

#[Test]
public function returns_2_if_trustCorporation_is_inactive(): void
Expand All @@ -74,6 +137,65 @@ public function returns_2_if_trustCorporation_is_inactive(): void
$this->loggerProphecy->reveal()
);

$this->assertEquals(2, ($status)($trustCorporation));
}
#[Test]
public function returns_2_if_trustCorporation_is_inactive_combined_format_lpastore(): void
{
$trustCorporation = new LpaStoreTrustCorporations(
$addressLine1 = '103 Line 1',
$addressLine2 = null,
$addressLine3 = null,
$country = 'GB',
$county = null,
$companyName = 'XYZ Ltd',
$dob = null,
$email = null,
$firstname = null,
$firstnames = null,
$name = '',
$otherNames = null,
$postcode = null,
$surname = null,
$systemStatus = 'false',
$town = 'Town',
$type = null,
$uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(2, ($status)($trustCorporation));
}
#[Test]
public function returns_2_if_trustCorporation_is_inactive_combined_format_sirius(): void
{
$trustCorporation = new SiriusLpaTrustCorporations(
$addressLine1 = 'Street 1',
$addressLine2 = 'Street 2',
$addressLine3 = 'Street 3',
$country = 'GB',
$county = 'County',
$dob = null,
$email = null,
$firstname = 'trust',
$firstnames = null,
$name = 'XYZ Ltd',
$otherNames = null,
$postcode = 'ABC 123',
$surname = 'test',
$systemStatus = 'false',
$town = 'Town',
$type = 'Primary',
$uId = '7000-0015-1998',
);

$status = new GetTrustCorporationStatus(
$this->loggerProphecy->reveal()
);

$this->assertEquals(2, ($status)($trustCorporation));
}
}

0 comments on commit 8e753df

Please sign in to comment.