diff --git a/docker-compose.yml b/docker-compose.yml index 4c4e667a78..67ea6bfbfe 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -66,6 +66,7 @@ services: XDEBUG_MODE: develop,debug,coverage SESSION_EXPIRES: 30 # session expiry length to support timeout message. COOKIE_EXPIRES: 1440 # cookie expiry for complete logout - initial value to be 24 hours. + SUPPORT_DATASTORE_LPAS: "false" depends_on: - api-web diff --git a/service-front/app/src/Common/src/Entity/Address.php b/service-front/app/src/Common/src/Entity/Address.php index 74bdb876a9..a90f36da11 100644 --- a/service-front/app/src/Common/src/Entity/Address.php +++ b/service-front/app/src/Common/src/Entity/Address.php @@ -6,7 +6,7 @@ class Address { - protected int $id; + protected ?int $id = null; protected ?string $town = null; protected ?string $county = null; protected ?string $postcode = null; @@ -16,14 +16,15 @@ class Address protected ?string $addressLine2 = null; protected ?string $addressLine3 = null; - public function getId(): int + public function getId(): ?int { return $this->id; } - public function setId(int $id): void + public function setId(int $id): self { $this->id = $id; + return $this; } public function getTown(): ?string @@ -31,9 +32,10 @@ public function getTown(): ?string return $this->town; } - public function setTown(string $town): void + public function setTown(string $town): self { $this->town = $town; + return $this; } public function getCounty(): ?string @@ -41,9 +43,10 @@ public function getCounty(): ?string return $this->county; } - public function setCounty(string $county): void + public function setCounty(?string $county): self { $this->county = $county; + return $this; } public function getPostcode(): ?string @@ -51,9 +54,10 @@ public function getPostcode(): ?string return $this->postcode; } - public function setPostcode(string $postcode): void + public function setPostcode(string $postcode): self { $this->postcode = $postcode; + return $this; } public function getCountry(): ?string @@ -61,9 +65,10 @@ public function getCountry(): ?string return $this->country; } - public function setCountry(string $country): void + public function setCountry(?string $country): self { $this->country = $country; + return $this; } public function getType(): ?string @@ -71,9 +76,10 @@ public function getType(): ?string return $this->type; } - public function setType(string $type): void + public function setType(string $type): self { $this->type = $type; + return $this; } public function getAddressLine1(): ?string @@ -81,9 +87,10 @@ public function getAddressLine1(): ?string return $this->addressLine1; } - public function setAddressLine1(string $addressLine1): void + public function setAddressLine1(string $addressLine1): self { $this->addressLine1 = $addressLine1; + return $this; } public function getAddressLine2(): ?string @@ -91,9 +98,10 @@ public function getAddressLine2(): ?string return $this->addressLine2; } - public function setAddressLine2(string $addressLine2): void + public function setAddressLine2(?string $addressLine2): self { $this->addressLine2 = $addressLine2; + return $this; } public function getAddressLine3(): ?string @@ -101,8 +109,9 @@ public function getAddressLine3(): ?string return $this->addressLine3; } - public function setAddressLine3(string $addressLine3): void + public function setAddressLine3(?string $addressLine3): self { $this->addressLine3 = $addressLine3; + return $this; } } diff --git a/service-front/app/src/Common/src/Entity/Casters/CastToCaseSubtype.php b/service-front/app/src/Common/src/Entity/Casters/CastToCaseSubtype.php index e2e8492b26..fde91da5d6 100644 --- a/service-front/app/src/Common/src/Entity/Casters/CastToCaseSubtype.php +++ b/service-front/app/src/Common/src/Entity/Casters/CastToCaseSubtype.php @@ -12,8 +12,12 @@ #[Attribute(Attribute::TARGET_PARAMETER)] class CastToCaseSubtype implements PropertyCaster { - public function cast(mixed $value, ObjectMapper $hydrator): string + public function cast(mixed $value, ObjectMapper $hydrator): ?string { - return LpaType::fromShortName($value)->value; + if (is_null(LpaType::tryFrom($value))) { + return LpaType::fromShortName($value)->value; + } + + return LpaType::from($value)->value; } } diff --git a/service-front/app/src/Common/src/Entity/Casters/CastToHowAttorneysMakeDecisions.php b/service-front/app/src/Common/src/Entity/Casters/CastToHowAttorneysMakeDecisions.php new file mode 100644 index 0000000000..803ae9b490 --- /dev/null +++ b/service-front/app/src/Common/src/Entity/Casters/CastToHowAttorneysMakeDecisions.php @@ -0,0 +1,20 @@ +value; + } +} diff --git a/service-front/app/src/Common/src/Entity/Casters/CastToLifeSustainingTreatment.php b/service-front/app/src/Common/src/Entity/Casters/CastToLifeSustainingTreatment.php index 11b6704220..1237a5d015 100644 --- a/service-front/app/src/Common/src/Entity/Casters/CastToLifeSustainingTreatment.php +++ b/service-front/app/src/Common/src/Entity/Casters/CastToLifeSustainingTreatment.php @@ -6,6 +6,7 @@ use Common\Enum\LifeSustainingTreatment; use Attribute; +use Common\Enum\LpaType; use EventSauce\ObjectHydrator\ObjectMapper; use EventSauce\ObjectHydrator\PropertyCaster; @@ -14,6 +15,10 @@ class CastToLifeSustainingTreatment implements PropertyCaster { public function cast(mixed $value, ObjectMapper $hydrator): mixed { + if (is_null(LifeSustainingTreatment::tryFrom($value))) { + return LifeSustainingTreatment::fromShortName($value)->value; + } + return LifeSustainingTreatment::from($value)->value; } } diff --git a/service-front/app/src/Common/src/Entity/Casters/CastToWhenTheLpaCanBeUsed.php b/service-front/app/src/Common/src/Entity/Casters/CastToWhenTheLpaCanBeUsed.php index e9407be681..adc5df7566 100644 --- a/service-front/app/src/Common/src/Entity/Casters/CastToWhenTheLpaCanBeUsed.php +++ b/service-front/app/src/Common/src/Entity/Casters/CastToWhenTheLpaCanBeUsed.php @@ -4,8 +4,8 @@ namespace Common\Entity\Casters; -use Common\Enum\HowAttorneysMakeDecisions; use Attribute; +use Common\Enum\WhenTheLpaCanBeUsed; use EventSauce\ObjectHydrator\ObjectMapper; use EventSauce\ObjectHydrator\PropertyCaster; @@ -14,6 +14,14 @@ class CastToWhenTheLpaCanBeUsed implements PropertyCaster { public function cast(mixed $value, ObjectMapper $hydrator): ?string { - return HowAttorneysMakeDecisions::from($value)->value; + if (is_null(WhenTheLpaCanBeUsed::tryFrom($value))) { + $value = match ($value) { + 'when registered' => WhenTheLpaCanBeUsed::WHEN_HAS_CAPACITY->value, + 'loss of capacity' => WhenTheLpaCanBeUsed::WHEN_CAPACITY_LOST->value, + default => '', + }; + } + + return WhenTheLpaCanBeUsed::from($value)->value; } } diff --git a/service-front/app/src/Common/src/Entity/Casters/ExtractPostcodeFromLpaStore.php b/service-front/app/src/Common/src/Entity/Casters/ExtractPostcodeFromLpaStore.php new file mode 100644 index 0000000000..06027f9962 --- /dev/null +++ b/service-front/app/src/Common/src/Entity/Casters/ExtractPostcodeFromLpaStore.php @@ -0,0 +1,22 @@ +format('Y-m-d H:i:s.uO'); - } - }); - - return $data; - } - public function getLpaDonorSignatureDate(): ?DateTimeImmutable { return $this->lpaDonorSignatureDate; @@ -84,4 +76,59 @@ public function getCaseSubtype(): string { return $this->caseSubtype->value; } + + public function getStatus(): ?string + { + return $this->status; + } + + public function getLifeSustainingTreatment(): string + { + return $this->lifeSustainingTreatment->value; + } + + public function getHowAttorneysMakeDecisions(): HowAttorneysMakeDecisions + { + return $this->howAttorneysMakeDecisions; + } + + public function getCaseAttorneySingular(): bool + { + return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::SINGULAR; + } + + public function getCaseAttorneyJointly(): bool + { + return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::JOINTLY; + } + + public function getCaseAttorneyJointlyAndSeverally(): bool + { + return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::JOINTLY_AND_SEVERALLY; + } + + public function getCaseAttorneyJointlyAndJointlyAndSeverally(): bool + { + return $this->howAttorneysMakeDecisions === HowAttorneysMakeDecisions::JOINTLY_FOR_SOME_SEVERALLY_FOR_OTHERS; + } + + public function getActiveAttorneys(): ?array + { + return $this->attorneys; + } + + public function getTrustCorporations(): ?array + { + return $this->trustCorporations; + } + + public function getWhenTheLpaCanBeUsed(): WhenTheLpaCanBeUsed + { + return $this->whenTheLpaCanBeUsed; + } + + public function getLpaType(): LpaType + { + return LpaType::from($this->getCaseSubtype()); + } } diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStore.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStore.php index b442ded1a2..f58d77040f 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStore.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStore.php @@ -6,27 +6,24 @@ use Common\Entity\Casters\CastSingleDonor; use Common\Entity\Casters\CastToCaseSubtype; +use Common\Entity\Casters\CastToHowAttorneysMakeDecisions; use Common\Entity\Casters\CastToLifeSustainingTreatment; use Common\Entity\Casters\CastToWhenTheLpaCanBeUsed; use Common\Entity\CombinedLpa; use Common\Enum\HowAttorneysMakeDecisions; use Common\Enum\LifeSustainingTreatment; use Common\Enum\LpaType; +use Common\Enum\WhenTheLpaCanBeUsed; use DateTimeImmutable; -use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastListToType; -use JsonSerializable; -class LpaStore extends CombinedLpa implements JsonSerializable +class LpaStore extends CombinedLpa { public function __construct( ?bool $applicationHasGuidance, ?bool $applicationHasRestrictions, ?string $applicationType, - #[MapFrom('howAttorneysMakeDecisions')] - #[CastToWhenTheLpaCanBeUsed] - ?HowAttorneysMakeDecisions $attorneyActDecisions, #[CastListToType(LpaStoreAttorney::class)] ?array $attorneys, #[MapFrom('lpaType')] @@ -37,6 +34,9 @@ public function __construct( #[CastSingleDonor] ?object $donor, ?bool $hasSeveranceWarning, + #[MapFrom('howAttorneysMakeDecisions')] + #[CastToHowAttorneysMakeDecisions] + ?HowAttorneysMakeDecisions $howAttorneysMakeDecisions, ?DateTimeImmutable $invalidDate, #[MapFrom('lifeSustainingTreatmentOption')] #[CastToLifeSustainingTreatment] @@ -56,18 +56,21 @@ public function __construct( #[MapFrom('uid')] ?string $uId, ?DateTimeImmutable $withdrawnDate, + #[MapFrom('whenTheLpaCanBeUsed')] + #[CastToWhenTheLpaCanBeUsed] + ?WhenTheLpaCanBeUsed $whenTheLpaCanBeUsed, ) { parent::__construct( $applicationHasGuidance, $applicationHasRestrictions, $applicationType, - $attorneyActDecisions, $attorneys, $caseSubtype, $channel, $dispatchDate, $donor, $hasSeveranceWarning, + $howAttorneysMakeDecisions, $invalidDate, $lifeSustainingTreatment, $lpaDonorSignatureDate, @@ -81,21 +84,8 @@ public function __construct( $statusDate, $trustCorporations, $uId, - $withdrawnDate + $withdrawnDate, + $whenTheLpaCanBeUsed ); } - - #[DoNotSerialize] - public function jsonSerialize(): mixed - { - $data = get_object_vars($this); - - array_walk($data, function (&$value) { - if ($value instanceof DateTimeImmutable) { - $value = $value->format('Y-m-d H:i:s.uO'); - } - }); - - return $data; - } } diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php index 5b5fc2790e..cd0b593ede 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreAttorney.php @@ -6,21 +6,20 @@ use Common\Entity\Casters\ExtractAddressLine1FromLpaStore; use Common\Entity\Casters\ExtractCountryFromLpaStore; +use Common\Entity\Casters\ExtractPostcodeFromLpaStore; use Common\Entity\Casters\ExtractTownFromLpaStore; use Common\Entity\Person; use DateTimeImmutable; -use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; -use JsonSerializable; -class LpaStoreAttorney extends Person implements JsonSerializable +class LpaStoreAttorney extends Person { public function __construct( #[MapFrom('address')] #[ExtractAddressLine1FromLpaStore] - ?string $addressLine1, - ?string $addressLine2, - ?string $addressLine3, + ?string $line1, + ?string $line2, + ?string $line3, #[MapFrom('address')] #[ExtractCountryFromLpaStore] ?string $country, @@ -34,6 +33,8 @@ public function __construct( ?string $firstnames, ?string $name, ?string $otherNames, + #[MapFrom('address')] + #[ExtractPostcodeFromLpaStore] ?string $postcode, #[MapFrom('lastName')] ?string $surname, @@ -47,9 +48,9 @@ public function __construct( ?string $uId, ) { parent::__construct( - $addressLine1, - $addressLine2, - $addressLine3, + $line1, + $line2, + $line3, $country, $county, $dob, @@ -66,18 +67,4 @@ public function __construct( $uId, ); } - - #[DoNotSerialize] - public function jsonSerialize(): mixed - { - $data = get_object_vars($this); - - array_walk($data, function (&$value) { - if ($value instanceof DateTimeImmutable) { - $value = $value->format('Y-m-d H:i:s.uO'); - } - }); - - return $data; - } } diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php index 016751441a..17be4bd4b3 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreDonor.php @@ -6,21 +6,20 @@ use Common\Entity\Casters\ExtractAddressLine1FromLpaStore; use Common\Entity\Casters\ExtractCountryFromLpaStore; +use Common\Entity\Casters\ExtractPostcodeFromLpaStore; use Common\Entity\Casters\ExtractTownFromLpaStore; use Common\Entity\Person; use DateTimeImmutable; -use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; -use JsonSerializable; -class LpaStoreDonor extends Person implements JsonSerializable +class LpaStoreDonor extends Person { public function __construct( #[MapFrom('address')] #[ExtractAddressLine1FromLpaStore] - ?string $addressLine1, - ?string $addressLine2, - ?string $addressLine3, + ?string $line1, + ?string $line2, + ?string $line3, #[MapFrom('address')] #[ExtractCountryFromLpaStore] ?string $country, @@ -33,6 +32,8 @@ public function __construct( ?string $firstnames, ?string $name, ?string $otherNames, + #[MapFrom('address')] + #[ExtractPostcodeFromLpaStore] ?string $postcode, #[MapFrom('lastName')] ?string $surname, @@ -46,9 +47,9 @@ public function __construct( ?string $uId, ) { parent::__construct( - $addressLine1, - $addressLine2, - $addressLine3, + $line1, + $line2, + $line3, $country, $county, $dob, @@ -65,18 +66,4 @@ public function __construct( $uId, ); } - - #[DoNotSerialize] - public function jsonSerialize(): mixed - { - $data = get_object_vars($this); - - array_walk($data, function (&$value) { - if ($value instanceof DateTimeImmutable) { - $value = $value->format('Y-m-d H:i:s.uO'); - } - }); - - return $data; - } } diff --git a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php index b53dfea21f..10e83d3a13 100644 --- a/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php +++ b/service-front/app/src/Common/src/Entity/LpaStore/LpaStoreTrustCorporations.php @@ -6,6 +6,7 @@ use Common\Entity\Casters\ExtractAddressLine1FromLpaStore; use Common\Entity\Casters\ExtractCountryFromLpaStore; +use Common\Entity\Casters\ExtractPostcodeFromLpaStore; use Common\Entity\Casters\ExtractTownFromLpaStore; use Common\Entity\Person; use DateTimeImmutable; @@ -16,9 +17,9 @@ class LpaStoreTrustCorporations extends Person public function __construct( #[MapFrom('address')] #[ExtractAddressLine1FromLpaStore] - ?string $addressLine1, - ?string $addressLine2, - ?string $addressLine3, + ?string $line1, + ?string $line2, + ?string $line3, #[MapFrom('name')] public readonly ?string $companyName, #[MapFrom('address')] @@ -32,6 +33,8 @@ public function __construct( ?string $firstnames, ?string $name, ?string $otherNames, + #[MapFrom('address')] + #[ExtractPostcodeFromLpaStore] ?string $postcode, ?string $surname, #[MapFrom('status')] @@ -44,9 +47,9 @@ public function __construct( ?string $uId, ) { parent::__construct( - $addressLine1, - $addressLine2, - $addressLine3, + $line1, + $line2, + $line3, $country, $county, $dob, diff --git a/service-front/app/src/Common/src/Entity/Person.php b/service-front/app/src/Common/src/Entity/Person.php index 4ef7eba0af..35f71c6eaa 100644 --- a/service-front/app/src/Common/src/Entity/Person.php +++ b/service-front/app/src/Common/src/Entity/Person.php @@ -5,6 +5,7 @@ namespace Common\Entity; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; class Person { @@ -49,9 +50,63 @@ public function getSurname(): ?string return $this->surname; } - public function getDob(): DateTimeImmutable|null + public function getDob(): ?DateTimeImmutable { return $this->dob; } + public function getLine1(): ?string + { + return $this->addressLine1; + } + + public function getLine2(): ?string + { + return $this->addressLine2; + } + + public function getLine3(): ?string + { + return $this->addressLine3; + } + + public function getTown(): ?string + { + return $this->town; + } + + public function getCounty(): ?string + { + return $this->county; + } + + public function getPostCode(): ?string + { + return $this->postcode; + } + + public function getCountry(): ?string + { + return $this->country; + } + + + public function getCompanyName(): ?string + { + return $this->name; + } + + public function getAddresses(): array + { + return [ + (new Address()) + ->setAddressLine1($this->getLine1()) + ->setAddressLine2($this->getLine2()) + ->setAddressLine3($this->getLine3()) + ->setTown($this->getTown()) + ->setCounty($this->getCounty()) + ->setPostcode($this->getPostCode()) + ->setCountry($this->getCountry()), + ]; + } } diff --git a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpa.php b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpa.php index e6aa758825..402e699395 100644 --- a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpa.php +++ b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpa.php @@ -4,12 +4,16 @@ namespace Common\Entity\Sirius; +use Common\Entity\Casters\CastToCaseSubtype; +use Common\Entity\Casters\CastToHowAttorneysMakeDecisions; use Common\Entity\Casters\CastToWhenTheLpaCanBeUsed; use Common\Entity\CombinedLpa; use Common\Enum\HowAttorneysMakeDecisions; use Common\Enum\LifeSustainingTreatment; use Common\Enum\LpaType; +use Common\Enum\WhenTheLpaCanBeUsed; use DateTimeImmutable; +use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastListToType; use Common\Entity\Casters\CastSiriusDonor; use Common\Entity\Casters\CastToSiriusLifeSustainingTreatment; @@ -20,16 +24,17 @@ public function __construct( ?bool $applicationHasGuidance, ?bool $applicationHasRestrictions, ?string $applicationType, - #[CastToWhenTheLpaCanBeUsed] - ?HowAttorneysMakeDecisions $attorneyActDecisions, #[CastListToType(SiriusLpaAttorney::class)] ?array $attorneys, + #[CastToCaseSubtype] ?LpaType $caseSubtype, ?string $channel, ?DateTimeImmutable $dispatchDate, #[CastSiriusDonor] ?object $donor, ?bool $hasSeveranceWarning, + #[CastToHowAttorneysMakeDecisions] + ?HowAttorneysMakeDecisions $howAttorneysMakeDecisions, ?DateTimeImmutable $invalidDate, #[CastToSiriusLifeSustainingTreatment] ?LifeSustainingTreatment $lifeSustainingTreatment, @@ -47,18 +52,21 @@ public function __construct( ?array $trustCorporations, ?string $uId, ?DateTimeImmutable $withdrawnDate, + #[MapFrom('whenTheLpaCanBeUsed')] + #[CastToWhenTheLpaCanBeUsed] + ?WhenTheLpaCanBeUsed $whenTheLpaCanBeUsed, ) { parent::__construct( $applicationHasGuidance, $applicationHasRestrictions, $applicationType, - $attorneyActDecisions, $attorneys, $caseSubtype, $channel, $dispatchDate, $donor, $hasSeveranceWarning, + $howAttorneysMakeDecisions, $invalidDate, $lifeSustainingTreatment, $lpaDonorSignatureDate, @@ -72,7 +80,8 @@ public function __construct( $statusDate, $trustCorporations, $uId, - $withdrawnDate + $withdrawnDate, + $whenTheLpaCanBeUsed ); } } diff --git a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaAttorney.php b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaAttorney.php index 222e6ad0c3..a7bb50936e 100644 --- a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaAttorney.php +++ b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaAttorney.php @@ -4,7 +4,6 @@ namespace Common\Entity\Sirius; -use EventSauce\ObjectHydrator\DoNotSerialize; use Common\Entity\Casters\{ ExtractAddressLine1FromSiriusLpa, ExtractAddressLine2FromSiriusLpa, @@ -19,9 +18,8 @@ use EventSauce\ObjectHydrator\MapFrom; use DateTimeImmutable; use EventSauce\ObjectHydrator\PropertyCasters\CastToType; -use JsonSerializable; -class SiriusLpaAttorney extends Person implements JsonSerializable +class SiriusLpaAttorney extends Person { public function __construct( #[MapFrom('addresses')] @@ -81,18 +79,4 @@ public function __construct( $uId, ); } - - #[DoNotSerialize] - public function jsonSerialize(): mixed - { - $data = get_object_vars($this); - - array_walk($data, function (&$value) { - if ($value instanceof DateTimeImmutable) { - $value = $value->format('Y-m-d H:i:s.uO'); - } - }); - - return $data; - } } diff --git a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaDonor.php b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaDonor.php index 587fd55661..c4ee4a2d31 100644 --- a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaDonor.php +++ b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaDonor.php @@ -5,7 +5,6 @@ namespace Common\Entity\Sirius; use Common\Entity\Person; -use EventSauce\ObjectHydrator\DoNotSerialize; use Common\Entity\Casters\{ExtractAddressLine1FromSiriusLpa, ExtractAddressLine2FromSiriusLpa, ExtractAddressLine3FromSiriusLpa, @@ -18,9 +17,8 @@ use DateTimeImmutable; use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastToType; -use JsonSerializable; -class SiriusLpaDonor extends Person implements JsonSerializable +class SiriusLpaDonor extends Person { public function __construct( #[MapFrom('addresses')] @@ -83,18 +81,4 @@ public function __construct( $uId, ); } - - #[DoNotSerialize] - public function jsonSerialize(): mixed - { - $data = get_object_vars($this); - - array_walk($data, function (&$value) { - if ($value instanceof DateTimeImmutable) { - $value = $value->format('Y-m-d H:i:s.uO'); - } - }); - - return $data; - } } diff --git a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php index 8f0b07b2f0..719dcb221d 100644 --- a/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php +++ b/service-front/app/src/Common/src/Entity/Sirius/SiriusLpaTrustCorporations.php @@ -5,7 +5,6 @@ namespace Common\Entity\Sirius; use Common\Entity\Person; -use EventSauce\ObjectHydrator\DoNotSerialize; use Common\Entity\Casters\{ ExtractAddressLine1FromSiriusLpa, ExtractAddressLine2FromSiriusLpa, @@ -19,9 +18,8 @@ use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastToType; use DateTimeImmutable; -use JsonSerializable; -class SiriusLpaTrustCorporations extends Person implements JsonSerializable +class SiriusLpaTrustCorporations extends Person { public function __construct( #[MapFrom('addresses')] @@ -82,17 +80,8 @@ public function __construct( ); } - #[DoNotSerialize] - public function jsonSerialize(): mixed + public function getCompanyName(): ?string { - $data = get_object_vars($this); - - array_walk($data, function (&$value) { - if ($value instanceof DateTimeImmutable) { - $value = $value->format('Y-m-d H:i:s.uO'); - } - }); - - return $data; + return $this->name; } } diff --git a/service-front/app/src/Common/src/Enum/HowAttorneysMakeDecisions.php b/service-front/app/src/Common/src/Enum/HowAttorneysMakeDecisions.php index d41f397a8e..cf06f8f4b4 100644 --- a/service-front/app/src/Common/src/Enum/HowAttorneysMakeDecisions.php +++ b/service-front/app/src/Common/src/Enum/HowAttorneysMakeDecisions.php @@ -10,4 +10,24 @@ enum HowAttorneysMakeDecisions: string case JOINTLY = 'jointly'; case JOINTLY_AND_SEVERALLY = 'jointly-and-severally'; case JOINTLY_FOR_SOME_SEVERALLY_FOR_OTHERS = 'jointly-for-some-severally-for-others'; + + public function isSingular(): bool + { + return $this === HowAttorneysMakeDecisions::SINGULAR; + } + + public function isJointly(): bool + { + return $this === HowAttorneysMakeDecisions::JOINTLY; + } + + public function isJointlyAndSeverally(): bool + { + return $this === HowAttorneysMakeDecisions::JOINTLY_AND_SEVERALLY; + } + + public function isJointlyForSomeSeverallyForOthers(): bool + { + return $this === HowAttorneysMakeDecisions::JOINTLY_FOR_SOME_SEVERALLY_FOR_OTHERS; + } } diff --git a/service-front/app/src/Common/src/Enum/LifeSustainingTreatment.php b/service-front/app/src/Common/src/Enum/LifeSustainingTreatment.php index 633b8c5b28..e575b4ce8f 100644 --- a/service-front/app/src/Common/src/Enum/LifeSustainingTreatment.php +++ b/service-front/app/src/Common/src/Enum/LifeSustainingTreatment.php @@ -19,4 +19,14 @@ public static function fromShortName(string $shortName): self default => throw new InvalidArgumentException('Invalid shorthand name: ' . $shortName), }; } + + public function isOptionA(): bool + { + return $this === self::OPTION_A; + } + + public function isOptionB(): bool + { + return $this === self::OPTION_B; + } } diff --git a/service-front/app/src/Common/src/Enum/LpaType.php b/service-front/app/src/Common/src/Enum/LpaType.php index e29f90c66c..0cd0ef3c8b 100644 --- a/service-front/app/src/Common/src/Enum/LpaType.php +++ b/service-front/app/src/Common/src/Enum/LpaType.php @@ -19,4 +19,14 @@ public static function fromShortName(string $shortName): self default => throw new InvalidArgumentException('Invalid shorthand name: ' . $shortName), }; } + + public function isPersonalWelfare(): bool + { + return $this === self::PERSONAL_WELFARE; + } + + public function isPropertyAndAffairs(): bool + { + return $this === self::PROPERTY_AND_AFFAIRS; + } } diff --git a/service-front/app/src/Common/src/Enum/WhenTheLpaCanBeUsed.php b/service-front/app/src/Common/src/Enum/WhenTheLpaCanBeUsed.php new file mode 100644 index 0000000000..6c6c505bdb --- /dev/null +++ b/service-front/app/src/Common/src/Enum/WhenTheLpaCanBeUsed.php @@ -0,0 +1,27 @@ +hydrateObject($lpa); - - return $lpaObject; + return $this->hydrateObject($lpa); } /** diff --git a/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php b/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php index c650081c6c..e72031d7b4 100644 --- a/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php +++ b/service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php @@ -33,7 +33,7 @@ public function __construct( * Currently, fairly naive in its assumption that the data types are stored under explicit keys, which * may change. * - * @param array{ + * @param array{ * lpa: array, * actor?: array, * iap?: array, @@ -49,7 +49,9 @@ public function __invoke(array $data): ArrayObject //introduce feature flag here #3551 //the lpaData array converted to object using hydrator if (($this->featureEnabled)('support_datastore_lpas')) { - $mockedCombinedLpa = $this->getMockedCombinedFormat(); + // Set asLpaStoreLpa to toggle the format of the response (but ensure + // its set to false before running tests) + $mockedCombinedLpa = self::getMockedCombinedFormat(false); $data['lpa'] = ($this->lpaDataFormatter)($mockedCombinedLpa); } else { $data['lpa'] = $this->lpaFactory->createLpaFromData($dataItem); @@ -71,32 +73,35 @@ public function __invoke(array $data): ArrayObject return new ArrayObject($data, ArrayObject::ARRAY_AS_PROPS); } - private function getMockedCombinedFormat(): array + /** + * @codeCoverageIgnore + */ + public static function getMockedCombinedFormat(bool $asLpaStoreLpa): array { - return [ - 'id' => 2, - 'uId' => '700000000047', - 'receiptDate' => '2014-09-26', - 'registrationDate' => '2019-10-10', - 'rejectedDate' => null, - 'donor' => [ - 'id' => 7, - 'uId' => '700000000799', - 'linked' => [['id' => 7, 'uId' => '700000000799']], - 'dob' => '1948-11-01', - 'email' => 'RachelSanderson@opgtest.com', - 'salutation' => 'Mr', - 'firstname' => 'Rachel', + $lpa = [ + 'id' => 2, + 'uId' => '700000000047', + 'receiptDate' => '2014-09-26', + 'registrationDate' => '2019-10-10', + 'rejectedDate' => null, + 'donor' => [ + 'id' => 7, + 'uId' => '700000000799', + 'linked' => [['id' => 7, 'uId' => '700000000799']], + 'dob' => '1948-11-01', + 'email' => 'RachelSanderson@opgtest.com', + 'salutation' => 'Mr', + 'firstname' => 'Rachel', 'middlenames' => 'Emma', - 'surname' => 'Sanderson', - 'addresses' => [ + 'surname' => 'Sanderson', + 'addresses' => [ [ - 'id' => 7, - 'town' => '', - 'county' => '', - 'postcode' => 'DN37 5SH', - 'country' => '', - 'type' => 'Primary', + 'id' => 7, + 'town' => 'Townville', + 'county' => 'Countyville', + 'postcode' => 'DN37 5SH', + 'country' => '', + 'type' => 'Primary', 'addressLine1' => '81 Front Street', 'addressLine2' => 'LACEBY', 'addressLine3' => '', @@ -104,115 +109,115 @@ private function getMockedCombinedFormat(): array ], 'companyName' => null, ], - 'applicationType' => 'Classic', - 'caseSubtype' => 'hw', - 'status' => 'Registered', - 'lpaIsCleansed' => true, - 'caseAttorneySingular' => false, - 'caseAttorneyJointlyAndSeverally' => true, - 'caseAttorneyJointly' => false, + 'applicationType' => 'Classic', + 'caseSubtype' => 'pfa', + 'status' => 'Registered', + 'lpaIsCleansed' => true, + 'caseAttorneySingular' => false, + 'caseAttorneyJointlyAndSeverally' => true, + 'caseAttorneyJointly' => false, 'caseAttorneyJointlyAndJointlyAndSeverally' => false, - 'onlineLpaId' => 'A33718377316', - 'cancellationDate' => null, - 'attorneys' => [ + 'onlineLpaId' => 'A33718377316', + 'cancellationDate' => null, + 'attorneys' => [ [ - 'id' => 9, - 'uId' => '700000000815', - 'dob' => '1990-05-04', - 'email' => '', - 'salutation' => '', - 'firstname' => 'jean', - 'middlenames' => '', - 'surname' => 'sanderson', - 'addresses' => [ + 'id' => 9, + 'uId' => '700000000815', + 'dob' => '1990-05-04', + 'email' => '', + 'salutation' => '', + 'firstname' => 'Jean', + 'middlenames' => '', + 'surname' => 'Sanderson', + 'addresses' => [ [ - 'id' => 9, - 'town' => '', - 'county' => '', - 'postcode' => 'DN37 5SH', - 'country' => '', - 'type' => 'Primary', - 'addressLine1' => '9 high street', - 'addressLine2' => '', + 'id' => 9, + 'town' => 'Pretendham', + 'county' => 'Countyville', + 'postcode' => 'DN37 5SH', + 'country' => '', + 'type' => 'Primary', + 'addressLine1' => '9 High street', + 'addressLine2' => 'Pretendville', 'addressLine3' => '', ], ], 'systemStatus' => true, - 'companyName' => '', + 'companyName' => '', ], [ - 'id' => 12, - 'uId' => '7000-0000-0849', - 'dob' => '1975-10-05', - 'email' => 'XXXXX', - 'salutation' => 'Mrs', - 'firstname' => 'Ann', - 'middlenames' => '', - 'surname' => 'Summers', - 'addresses' => [ + 'id' => 12, + 'uId' => '7000-0000-0849', + 'dob' => '1975-10-05', + 'email' => 'XXXXX', + 'salutation' => 'Mrs', + 'firstname' => 'Ann', + 'middlenames' => '', + 'surname' => 'Summers', + 'addresses' => [ [ - 'id' => 12, - 'town' => '', - 'county' => '', - 'postcode' => '', - 'country' => '', - 'type' => 'Primary', - 'addressLine1' => '', - 'addressLine2' => '', + 'id' => 12, + 'town' => 'Hannerton', + 'county' => 'Countyville', + 'postcode' => 'HA1 4GH', + 'country' => '', + 'type' => 'Primary', + 'addressLine1' => '47 Armington Way', + 'addressLine2' => 'Hansville', 'addressLine3' => '', ], ], 'systemStatus' => true, - 'companyName' => '', + 'companyName' => '', ], ], - 'replacementAttorneys' => [], - 'trustCorporations' => [ + 'replacementAttorneys' => [], + 'trustCorporations' => [ [ - 'addresses' => [ + 'addresses' => [ [ - 'id' => 3207, - 'town' => 'Town', - 'county' => 'County', - 'postcode' => 'ABC 123', - 'country' => 'GB', - 'type' => 'Primary', + 'id' => 3207, + 'town' => 'Town', + 'county' => 'County', + 'postcode' => 'ABC 123', + 'country' => 'GB', + 'type' => 'Primary', 'addressLine1' => 'Street 1', 'addressLine2' => 'Street 2', 'addressLine3' => 'Street 3', ], ], - 'id' => 3485, - 'uId' => '7000-0015-1998', - 'dob' => null, - 'email' => null, - 'salutation' => null, - 'firstname' => 'trust', - 'middlenames' => null, - 'surname' => 'test', - 'otherNames' => null, + 'id' => 3485, + 'uId' => '7000-0015-1998', + 'dob' => null, + 'email' => null, + 'salutation' => null, + 'firstname' => 'trust', + 'middlenames' => null, + 'surname' => 'test', + 'otherNames' => null, 'systemStatus' => true, - 'companyName' => 'trust corporation', + 'name' => 'Trust Us Corporation Ltd.', ], ], - 'certificateProviders' => [ + 'certificateProviders' => [ [ - 'id' => 11, - 'uId' => '7000-0000-0831', - 'dob' => null, - 'email' => null, - 'salutation' => 'Miss', - 'firstname' => 'Danielle', + 'id' => 11, + 'uId' => '7000-0000-0831', + 'dob' => null, + 'email' => null, + 'salutation' => 'Miss', + 'firstname' => 'Danielle', 'middlenames' => null, - 'surname' => 'Hart ', - 'addresses' => [ + 'surname' => 'Hart ', + 'addresses' => [ [ - 'id' => 11, - 'town' => '', - 'county' => '', - 'postcode' => 'SK14 0RH', - 'country' => '', - 'type' => 'Primary', + 'id' => 11, + 'town' => 'Townville', + 'county' => '', + 'postcode' => 'SK14 0RH', + 'country' => '', + 'type' => 'Primary', 'addressLine1' => '50 Fordham Rd', 'addressLine2' => 'HADFIELD', 'addressLine3' => '', @@ -220,11 +225,68 @@ private function getMockedCombinedFormat(): array ], ], ], - 'attorneyActDecisions' => null, - 'applicationHasRestrictions' => false, - 'applicationHasGuidance' => false, - 'lpaDonorSignatureDate' => '2012-12-12', - 'lifeSustainingTreatment' => 'Option A', + 'whenTheLpaCanBeUsed' => 'when-has-capacity', + 'applicationHasRestrictions' => false, + 'applicationHasGuidance' => false, + 'lpaDonorSignatureDate' => '2012-12-12', + 'lifeSustainingTreatment' => 'Option A', + 'howAttorneysMakeDecisions' => 'jointly', ]; + + if ($asLpaStoreLpa) { + $lpa['uId'] = 'M-123412341234'; + $lpa['howAttorneysMakeDecisions'] = 'jointly-and-severally'; + $lpa['lpaType'] = 'property-and-affairs'; + $lpa['lifeSustainingTreatment'] = 'option-a'; + $lpa['whenTheLpaCanBeUsed'] = 'when-has-capacity'; + + $lpa['donor']['address']['line1'] = $lpa['donor']['addresses'][0]['addressLine1']; + $lpa['donor']['address']['line2'] = $lpa['donor']['addresses'][0]['addressLine2']; + $lpa['donor']['address']['line3'] = $lpa['donor']['addresses'][0]['addressLine3']; + $lpa['donor']['address']['town'] = $lpa['donor']['addresses'][0]['town']; + $lpa['donor']['address']['postcode'] = $lpa['donor']['addresses'][0]['postcode']; + $lpa['donor']['address']['county'] = $lpa['donor']['addresses'][0]['county']; + $lpa['donor']['address']['country'] = $lpa['donor']['addresses'][0]['country']; + $lpa['donor']['dateOfBirth'] = $lpa['donor']['dob']; + + unset($lpa['donor']['addresses']); + unset($lpa['donor']['dob']); + + $lpa['attorneys'][0]['address']['line1'] = $lpa['attorneys'][0]['addresses'][0]['addressLine1']; + $lpa['attorneys'][0]['address']['line2'] = $lpa['attorneys'][0]['addresses'][0]['addressLine2']; + $lpa['attorneys'][0]['address']['line3'] = $lpa['attorneys'][0]['addresses'][0]['addressLine3']; + $lpa['attorneys'][0]['address']['town'] = $lpa['attorneys'][0]['addresses'][0]['town']; + $lpa['attorneys'][0]['address']['postcode'] = $lpa['attorneys'][0]['addresses'][0]['postcode']; + $lpa['attorneys'][0]['address']['county'] = $lpa['attorneys'][0]['addresses'][0]['county']; + $lpa['attorneys'][0]['address']['country'] = $lpa['attorneys'][0]['addresses'][0]['country']; + $lpa['attorneys'][0]['dateOfBirth'] = $lpa['attorneys'][0]['dob']; + + unset($lpa['attorneys'][0]['addresses']); + unset($lpa['attorneys'][0]['dob']); + + $lpa['attorneys'][1]['address']['line1'] = $lpa['attorneys'][1]['addresses'][0]['addressLine1']; + $lpa['attorneys'][1]['address']['line2'] = $lpa['attorneys'][1]['addresses'][0]['addressLine2']; + $lpa['attorneys'][1]['address']['line3'] = $lpa['attorneys'][1]['addresses'][0]['addressLine3']; + $lpa['attorneys'][1]['address']['town'] = $lpa['attorneys'][1]['addresses'][0]['town']; + $lpa['attorneys'][1]['address']['postcode'] = $lpa['attorneys'][1]['addresses'][0]['postcode']; + $lpa['attorneys'][1]['address']['county'] = $lpa['attorneys'][1]['addresses'][0]['county']; + $lpa['attorneys'][1]['address']['country'] = $lpa['attorneys'][1]['addresses'][0]['country']; + $lpa['attorneys'][1]['dateOfBirth'] = $lpa['attorneys'][1]['dob']; + + unset($lpa['attorneys'][1]['addresses']); + unset($lpa['attorneys'][1]['dob']); + + $lpa['trustCorporations'][0]['address']['line1'] = $lpa['trustCorporations'][0]['addresses'][0]['addressLine1']; + $lpa['trustCorporations'][0]['address']['line2'] = $lpa['trustCorporations'][0]['addresses'][0]['addressLine2']; + $lpa['trustCorporations'][0]['address']['line3'] = $lpa['trustCorporations'][0]['addresses'][0]['addressLine3']; + $lpa['trustCorporations'][0]['address']['town'] = $lpa['trustCorporations'][0]['addresses'][0]['town']; + $lpa['trustCorporations'][0]['address']['postcode'] = $lpa['trustCorporations'][0]['addresses'][0]['postcode']; + $lpa['trustCorporations'][0]['address']['county'] = $lpa['trustCorporations'][0]['addresses'][0]['county']; + $lpa['trustCorporations'][0]['address']['country'] = $lpa['trustCorporations'][0]['addresses'][0]['country']; + + unset($lpa['trustCorporations'][0]['addresses']); + } + + return $lpa; } } diff --git a/service-front/app/src/Common/src/Service/Pdf/PdfService.php b/service-front/app/src/Common/src/Service/Pdf/PdfService.php index 4f9de2cfa0..555b176205 100644 --- a/service-front/app/src/Common/src/Service/Pdf/PdfService.php +++ b/service-front/app/src/Common/src/Service/Pdf/PdfService.php @@ -4,8 +4,10 @@ namespace Common\Service\Pdf; +use Common\Entity\CombinedLpa; use Common\Entity\InstructionsAndPreferences\Images; use Common\Entity\Lpa; +use Common\Entity\Sirius\SiriusLpa; use Common\Exception\ApiException; use Common\Service\Log\EventCodes; use Common\Service\Log\RequestTracing; @@ -31,14 +33,14 @@ public function __construct( ) { } - public function getLpaAsPdf(Lpa $lpa, ?Images $images = null): StreamInterface + public function getLpaAsPdf(Lpa|SiriusLpa|CombinedLpa $lpa, ?Images $images = null): StreamInterface { $renderedLpa = $this->renderLpaAsHtml($lpa, $images); return $this->requestPdfFromService($renderedLpa); } - private function renderLpaAsHtml(Lpa $lpa, ?Images $images): string + private function renderLpaAsHtml(Lpa|SiriusLpa|CombinedLpa $lpa, ?Images $images): string { $renderData = [ 'lpa' => $lpa, @@ -49,14 +51,19 @@ private function renderLpaAsHtml(Lpa $lpa, ?Images $images): string $renderData['iap_images'] = $images; } + $template = 'viewer::download-lpa-combined-lpa'; + if ($lpa instanceof Lpa) { + $template = 'viewer::download-lpa'; + } + return $this->renderer->render( - 'viewer::download-lpa', + $template, $renderData, ); } /** - * @param string $htmlToRender + * @param string $htmlToRender * @return StreamInterface * @throws ApiException */ @@ -79,8 +86,8 @@ private function requestPdfFromService(string $htmlToRender): StreamInterface $this->logger->notice( 'Successfully generated PDF and presented for download {code}', [ - 'event_code' => EventCodes::DOWNLOAD_SUMMARY, - 'code' => $response->getStatusCode(), + 'event_code' => EventCodes::DOWNLOAD_SUMMARY, + 'code' => $response->getStatusCode(), ] ); diff --git a/service-front/app/src/Common/src/View/Twig/LpaExtension.php b/service-front/app/src/Common/src/View/Twig/LpaExtension.php index 5a81d4b15e..048c3d4439 100644 --- a/service-front/app/src/Common/src/View/Twig/LpaExtension.php +++ b/service-front/app/src/Common/src/View/Twig/LpaExtension.php @@ -6,8 +6,8 @@ use Common\Entity\Person; use Common\Entity\CaseActor; -use Common\Entity\Lpa; use Common\Entity\CombinedLpa; +use Common\Entity\Lpa; use DateTime; use DateTimeInterface; use Exception; @@ -38,21 +38,26 @@ public function getFunctions(): array ]; } - public function actorAddress(CaseActor $actor): string + public function actorAddress(CaseActor|Person $actor): string { // Multiple addresses can appear for an actor - just use the first one if (count($actor->getAddresses()) > 0) { $address = $actor->getAddresses()[0]; - return implode(', ', array_filter([ - $address->getAddressLine1(), - $address->getAddressLine2(), - $address->getAddressLine3(), - $address->getTown(), - $address->getCounty(), - $address->getPostcode(), - $address->getCountry(), - ])); + return implode( + ', ', + array_filter( + [ + $address->getAddressLine1(), + $address->getAddressLine2(), + $address->getAddressLine3(), + $address->getTown(), + $address->getCounty(), + $address->getPostcode(), + $address->getCountry(), + ] + ) + ); } return ''; @@ -61,7 +66,7 @@ public function actorAddress(CaseActor $actor): string /** * Removes the dob from the string and returns just donor name * - * @param string $donorNameAndDob + * @param string $donorNameAndDob * @return string */ public function donorNameWithDobRemoved(string $donorNameAndDob): string @@ -71,8 +76,8 @@ public function donorNameWithDobRemoved(string $donorNameAndDob): string } /** - * @param CaseActor|Person $actor - * @param bool $withSalutation Prepend salutation? + * @param CaseActor|Person $actor + * @param bool $withSalutation Prepend salutation? * @return string */ public function actorName(CaseActor|Person $actor, bool $withSalutation = true): string @@ -94,7 +99,7 @@ public function actorName(CaseActor|Person $actor, bool $withSalutation = true): * Takes an input date, whether as a string (relative or absolute - in the format 2020-11-27) * or as a Datetime and converts it for displaying on pages * - * @param DateTimeInterface|string|null $date + * @param DateTimeInterface|string|null $date * @return string */ public function lpaDate(DateTimeInterface|string|null $date): string @@ -106,8 +111,8 @@ public function lpaDate(DateTimeInterface|string|null $date): string * Takes an input date, whether as a string (relative or absolute) or as a Datetime * and converts it for displaying on pages * - * @param DateTimeInterface|string|null $date - * @param string $parseFormat A PHP Datetime format string that should be used to parse $date + * @param DateTimeInterface|string|null $date + * @param string $parseFormat A PHP Datetime format string that should be used to parse $date * @return string */ public function formatDate(DateTimeInterface|string|null $date, string $parseFormat = 'Y-m-d\TH:i:sP'): string @@ -132,7 +137,7 @@ public function formatDate(DateTimeInterface|string|null $date, string $parseFor /** * Calculates the days remaining until the viewer code expires * - * @param string|null $expiryDate + * @param string|null $expiryDate * @return string * @throws Exception */ @@ -152,7 +157,7 @@ public function daysRemaining(?string $expiryDate): string /** * Checks whether the code has been cancelled * - * @param array $code + * @param array $code * @return bool|null */ public function isCodeCancelled(array $code): ?bool @@ -167,7 +172,7 @@ public function isCodeCancelled(array $code): ?bool /** * Checks whether the code has expired or not * - * @param string|null $expiryDate + * @param string|null $expiryDate * @return bool|null * @throws Exception */ @@ -184,7 +189,7 @@ public function hasCodeExpired(?string $expiryDate): ?bool /** * Create a hyphenated viewer code * - * @param string $viewerCode + * @param string $viewerCode * @return string */ public function formatViewerCode(string $viewerCode): string @@ -209,7 +214,7 @@ public function isDonorSignatureDateOld(Lpa|CombinedLpa $lpa): bool /** * Creates an international date formatter that is capable of doing locale based dates. * - * @param string $locale + * @param string $locale * @return IntlDateFormatter */ private function getDateFormatter(string $locale): IntlDateFormatter diff --git a/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig b/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig new file mode 100644 index 0000000000..ba62b47403 --- /dev/null +++ b/service-front/app/src/Common/templates/partials/full-lpa-display-combined-lpa.html.twig @@ -0,0 +1,160 @@ +
+
+
+
+ {% if is_lpa_cancelled(lpa) %} +

+ {% if lpa.lpaType.propertyAndAffairs %} + {% trans %}This property and finance LPA has been cancelled{% endtrans %} + {% else %} + {% trans %}This health and welfare LPA has been cancelled{% endtrans %} + {% endif %} +

+
+ {% if lpa.cancellationDate is not null %} + {% trans with {'%cancellationDate%': lpa_date(lpa.cancellationDate)} %}Cancelled on %cancellationDate%{% endtrans %} + {% endif %} + {% else %} +

+ {% if lpa.lpaType.propertyAndAffairs and lpa.whenTheLpaCanBeUsed.whenHasCapacity %} + {% trans %}This property and finance LPA is valid and can be used now{% endtrans %} + {% else %} + {% if lpa.lpaType.propertyAndAffairs %} + {% trans %}This property and finance LPA is valid{% endtrans %} + {% else %} + {% trans %}This health and welfare LPA is valid{% endtrans %} + {% endif %} + {% endif %} +

+
+

+ {% if lpa.lpaType.propertyAndAffairs %} + {% if lpa.whenTheLpaCanBeUsed.whenCapacityLost %} + {% trans %}This LPA can only be used when the donor has lost capacity{% endtrans %} + {% elseif lpa.whenTheLpaCanBeUsed.unknown %} + {% trans %}This LPA can be used as soon as it's registered unless instructions say otherwise{% endtrans %} + {% endif %} + {% else %} + {% if lpa.lifeSustainingTreatment.OptionA %} + {% trans %}The attorneys have the authority to make decisions about life-sustaining treatment{% endtrans %} + {% elseif lpa.lifeSustainingTreatment.OptionB %} + {% trans %}The attorneys do NOT have the authority to make decisions about life-sustaining treatment{% endtrans %} + {% endif %} + {% endif %} +

+ {% endif %} + + {% if lpa.applicationHasGuidance or lpa.applicationHasRestrictions %} +

+ {% if is_donor_signature_date_too_old(lpa) %} + {% trans %}This LPA has instructions and/or preferences{% endtrans %} + {% elseif lpa.applicationHasGuidance and lpa.applicationHasRestrictions %} + {% trans %}This LPA has instructions and preferences{% endtrans %} + {% elseif lpa.applicationHasGuidance %} + {% trans %}This LPA has preferences{% endtrans %} + {% elseif lpa.applicationHasRestrictions %} + {% trans %}This LPA has instructions{% endtrans %} + {% endif %} +

+ {% endif %} +
+
+
+
+
+ {% if lpa.lpaType.propertyAndAffairs %} + {% set type = "Property and finance" %} + {% else %} + {% set type = "Health and welfare" %} + {% endif %} + +

{{ lpa.donor.firstname }} {{ lpa.donor.surname }}, {{ type|trans }}

+ + {% if not forDownload %} +
+ {% trans %}You should download and save this LPA summary. You can use it as evidence that you viewed the LPA summary before acting on it.{% endtrans %} +
+ +
+ +
+ {% endif %} +
+
+ + {{ include('@partials/section-break.html.twig') }} + +
+
+ {% include '@partials/lpa-summary-details/lpa-donor-details.html.twig' %} +
+
+ + {{ include('@partials/section-break.html.twig') }} + +
+
+ {% include '@partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig' %} +
+
+ + {{ include('@partials/section-break.html.twig') }} + +
+
+

+ {% trans %}LPA details{% endtrans %} +

+ + {% if feature_enabled("instructions_and_preferences") %} + {% include '@partials/lpa-summary-details/iap-images-components.html.twig' %} + + {% endif %} + + {% include '@partials/lpa-summary-details/lpa-details-combined-lpa.html.twig' %} + + {% if feature_enabled("instructions_and_preferences") and iap_images is defined %} + {% if iap_images.status is not constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_ERROR') %} +
+ {% trans %}If any scanned images are not readable, ask the person who gave you the access + code to show you the paper LPA.{% endtrans %} +
+ {% endif %} + {% endif %} + + {% if feature_enabled("instructions_and_preferences") %} +
+ {% endif %} + +
+
+
{% trans %}Date summary viewed{% endtrans %}
+
{{ lpa_date('today') }}
+
+
+
+
+ + {{ include('@partials/section-break.html.twig') }} + + {% if not forDownload %} +
+
+
+ +
+

+ {% trans %}I want to check another LPA{% endtrans %} + +

+
+
+ {% endif %} +
+
+
diff --git a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig new file mode 100644 index 0000000000..7295bce707 --- /dev/null +++ b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details-combined-lpa.html.twig @@ -0,0 +1,57 @@ +

{% trans %}The attorneys{% endtrans %}

+
+
+
{% trans %}How decisions are made{% endtrans %}
+
+ {% if lpa.howAttorneysMakeDecisions.singular %} + {% trans %}Decisions are made by one attorney{% endtrans %} + {% elseif lpa.howAttorneysMakeDecisions.jointly %} + {% trans %}Attorneys must make decisions jointly (together){% endtrans %} + {% elseif lpa.howAttorneysMakeDecisions.jointlyAndSeverally %} + {% trans %}Attorneys can make decisions jointly (together) and severally (separately){% endtrans %} + {% elseif lpa.howAttorneysMakeDecisions.jointlyForSomeSeverallyForOthers %} + {% trans %}Attorneys must make some decisions jointly (together) and can make some decisions severally (separately). Check the paper + LPA to find out what decisions must be made jointly.{% endtrans %} + {% endif %} +
+
+
+ +{% for attorney in lpa.activeAttorneys %} +

{% trans count loop.index with {'%attorneyOrdinal%': loop.index | ordinal} %}%attorneyOrdinal% attorney|%attorneyOrdinal% attorney{% endtrans %}

+
+
+
{% trans %}Name{% endtrans %}
+
{{ actor_name(attorney) }}
+
+ {% if attorney.otherNames %} +
+
{% trans %}Also known as{% endtrans %}
+
{{ attorney.otherNames }}
+
+ {% endif %} +
+
{% trans %}Date of birth{% endtrans %}
+
{{ lpa_date(attorney.dob) }}
+
+
+
{% trans %}Address{% endtrans %}
+
{{ actor_address(attorney) }}
+
+
+{% endfor %} + +{% for tc in lpa.trustCorporations %} + {% set i = loop.index + lpa.activeAttorneys | length %} +

{% trans count i with {'%attorneyOrdinal%': i | ordinal } %}%attorneyOrdinal% attorney|%attorneyOrdinal% attorney{% endtrans %}

+
+
+
{% trans %}Name{% endtrans %}
+
{{ tc.companyName }} {% trans %}(Trust corporation){% endtrans %}
+
+
+
{% trans %}Address{% endtrans %}
+
{{ actor_address(tc) }}
+
+
+{% endfor %} diff --git a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig index 0d568bf2c5..9224071ad0 100644 --- a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig +++ b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-attorney-details.html.twig @@ -54,4 +54,4 @@
{{ actor_address(tc) }}
-{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-details-combined-lpa.html.twig b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-details-combined-lpa.html.twig new file mode 100644 index 0000000000..f6f1358782 --- /dev/null +++ b/service-front/app/src/Common/templates/partials/lpa-summary-details/lpa-details-combined-lpa.html.twig @@ -0,0 +1,175 @@ +{% import "@partials/lpa-summary-details/iap-macros.html.twig" as iap %} + +
+ {% if lpa.caseSubtype.propertyAndAffairs %} +
+
{% trans %}When can the LPA be used?{% endtrans %}
+
+ {% if lpa.whenTheLpaCanBeUsed.whenHasCapacity %} + {% if actor is defined and actor.type == 'donor' %} + {% trans %}You have said that this LPA can be used now. While you have mental capacity, your attorneys can only use the + LPA if you allow them to.{% endtrans %} + {% else %} + {% trans %}The donor has said that this LPA can be used now. While the donor has mental capacity, you can only use the + LPA if the donor allows you to.{% endtrans %} + {% endif %} + {% elseif lpa.whenTheLpaCanBeUsed.whenHasLostCapacity %} + {% trans %}This LPA can only be used when the donor has lost capacity{% endtrans %} + {% elseif lpa.whenTheLpaCanBeUsed.unknown %} + {% trans %}This LPA can be used as soon as it's registered unless instructions say otherwise.{% endtrans %} + {% endif %} +
+
+ {% else %} +
+
{% trans %}Life-sustaining +
treatment{% endtrans %}
+
+ {% if lpa.lifeSustainingTreatment.OptionA %} + {% trans %}The attorneys have the authority to make decisions about life-sustaining treatment{% endtrans %} + {% elseif lpa.lifeSustainingTreatment.OptionB %} + {% trans %}The attorneys do not have the authority to make decisions about life-sustaining treatment{% endtrans %} + {% else %} + {% trans %}To view this, ask to see the paper LPA{% endtrans %} + {% endif %} +
+
+ {% endif %} + +
+
{% trans %}Date donor signed LPA{% endtrans %}
+
{{ lpa_date(lpa.lpaDonorSignatureDate) }}
+
+ +
+
{% trans %}Registration date{% endtrans %}
+
{{ lpa_date(lpa.registrationDate) }}
+
+ +
+
{% trans %}LPA reference number{% endtrans %}
+
{{ lpa.uId }}
+
+ + {% if is_donor_signature_date_too_old(lpa) and (lpa.applicationHasGuidance or lpa.applicationHasRestrictions) and not feature_enabled("instructions_and_preferences") %} +
+
{% trans %}Instructions and preferences{% endtrans %}
+
+ {% trans %}Yes, the donor made instructions and/or preferences on their LPA.{% endtrans %} +
{% trans %}To view these, ask to see the paper LPA.{% endtrans %} +
+
+ {% elseif is_donor_signature_date_too_old(lpa) and not (lpa.applicationHasGuidance or lpa.applicationHasRestrictions) and not feature_enabled("instructions_and_preferences") %} +
+
{% trans %}Instructions and preferences{% endtrans %}
+
+ {% trans %}No{% endtrans %} +
+
+ {% else %} {# Instructions and Preferences are split OR I&P images are enabled #} +
+ + {% if feature_enabled('instructions_and_preferences') and (lpa.applicationHasGuidance or lpa.applicationHasRestrictions) %} + {% if lpa.hasSeveranceWarning %} +
+ + + {% trans %}Warning{% endtrans %} + {% trans %} + Some words in these instructions or preferences have been removed by the court of + protection. To check which words have been removed, please ask to see the paper + LPA or the court order. + {% endtrans %} + +
+ {% endif %} + {% endif %} + + +
+
+
{% trans %}Preferences{% endtrans %}
+
+ {% if lpa.applicationHasGuidance %} + {% if feature_enabled("instructions_and_preferences") and iap_images is defined %} + {% trans %}Yes, the donor made preferences on their LPA.{% endtrans %} + {% else %} + {% trans %}Yes, the donor made preferences on their LPA.{% endtrans %} +
{% trans %}To view these, ask to see the paper LPA.{% endtrans %} + {% endif %} + {% else %} + {% trans %}No{% endtrans %} + {% endif %} +
+
+
+ + {% if feature_enabled("instructions_and_preferences") and lpa.applicationHasGuidance and iap_images is defined %} + {% if iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_ERROR') %} + {{ iap.preferences_error() }} + {% elseif ((iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_IN_PROGRESS')) + or (iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_NOT_STARTED'))) %} + {{ iap.preferences_static_wait() }} + {% elseif iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_COMPLETE') %} + {% set prefs_images = iap_images.getPreferencesImageUrls %} + {% if (prefs_images | length) > 0 %} + {{ iap.images("preferences", prefs_images) }} + {% endif %} + {% endif %} + {% endif %} +
+ + +
+
+
{% trans %}Instructions{% endtrans %}
+
+ {% if lpa.applicationHasRestrictions %} + {% if feature_enabled("instructions_and_preferences") and iap_images is defined %} + {% trans %}Yes, the donor set instructions on their LPA.{% endtrans %} + {% else %} + {% trans %}Yes, the donor set instructions on their LPA.{% endtrans %} +
{% trans %}To view these, ask to see the paper LPA.{% endtrans %} + {% endif %} + {% else %} + {% trans %}No{% endtrans %} + {% endif %} +
+
+
+ + {% if feature_enabled("instructions_and_preferences") and lpa.applicationHasRestrictions and iap_images is defined %} + {% if iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_ERROR') %} + {{ iap.instructions_error() }} + {% elseif ((iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_IN_PROGRESS')) + or (iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_NOT_STARTED'))) %} + {{ iap.instructions_static_wait() }} + {% elseif iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_COMPLETE') %} + {% set insts_images = iap_images.getInstructionsImageUrls %} + {% if (insts_images | length) > 0 %} + {{ iap.images("instructions", insts_images) }} + {% endif %} + {% endif %} + {% endif %} +
+ + + {% if feature_enabled("instructions_and_preferences") and iap_images is defined and + iap_images.status is constant('\\Common\\Entity\\InstructionsAndPreferences\\ImagesStatus::COLLECTION_COMPLETE') %} + {% set unknown_images = iap_images.getUnknownImageUrls %} + {% if (unknown_images | length) > 0 %} + {{ iap.unknown_section() }} + + {{ iap.images("unknown", unknown_images) }} + {% endif %} + {% endif %} + + {% endif %} diff --git a/service-front/app/src/Viewer/src/Handler/CheckCodeHandler.php b/service-front/app/src/Viewer/src/Handler/CheckCodeHandler.php index 5f44bc927c..f41b45f7c0 100644 --- a/service-front/app/src/Viewer/src/Handler/CheckCodeHandler.php +++ b/service-front/app/src/Viewer/src/Handler/CheckCodeHandler.php @@ -12,6 +12,7 @@ use Common\Handler\Traits\Session as SessionTrait; use Common\Middleware\Security\UserIdentificationMiddleware; use Common\Middleware\Session\SessionTimeoutException; +use Common\Service\Features\FeatureEnabled; use Common\Service\Lpa\LpaService; use Common\Service\Security\RateLimitService; use DateTime; @@ -36,12 +37,13 @@ public function __construct( UrlHelper $urlHelper, private LpaService $lpaService, private RateLimitService $failureRateLimiter, + private FeatureEnabled $featureEnabled, ) { parent::__construct($renderer, $urlHelper); } /** - * @param ServerRequestInterface $request + * @param ServerRequestInterface $request * @return ResponseInterface * @throws \Http\Client\Exception|\Exception */ @@ -68,15 +70,23 @@ public function handle(ServerRequestInterface $request): ResponseInterface // Then we found a LPA for the given code $expires = new DateTime($lpa->expires); $status = strtolower($lpa->lpa->getStatus()); + + $templateName = 'viewer::check-code-found'; + if (($this->featureEnabled)('support_datastore_lpas')) { + $templateName = 'viewer::check-code-found-combined-lpa'; + } + if ($this->canDisplayLPA($status)) { - return new HtmlResponse($this->renderer->render( - 'viewer::check-code-found', - [ + return new HtmlResponse( + $this->renderer->render( + $templateName, + [ 'lpa' => $lpa->lpa, 'expires' => $expires->format('Y-m-d'), 'form' => $form, - ] - )); + ] + ) + ); } } } catch (ApiException $apiEx) { @@ -90,13 +100,15 @@ public function handle(ServerRequestInterface $request): ResponseInterface } $this->failureRateLimiter->limit($request->getAttribute(UserIdentificationMiddleware::IDENTIFY_ATTRIBUTE)); - return new HtmlResponse($this->renderer->render( - 'viewer::check-code-not-found', - [ + return new HtmlResponse( + $this->renderer->render( + 'viewer::check-code-not-found', + [ 'donor_last_name' => $surname, 'lpa_access_code' => $code, - ] - )); + ] + ) + ); } // We don't have a code so the session has timed out diff --git a/service-front/app/src/Viewer/src/Handler/Factory/CheckCodeHandlerFactory.php b/service-front/app/src/Viewer/src/Handler/Factory/CheckCodeHandlerFactory.php index 9d37d56bc7..a531506b0b 100644 --- a/service-front/app/src/Viewer/src/Handler/Factory/CheckCodeHandlerFactory.php +++ b/service-front/app/src/Viewer/src/Handler/Factory/CheckCodeHandlerFactory.php @@ -4,6 +4,7 @@ namespace Viewer\Handler\Factory; +use Common\Service\Features\FeatureEnabled; use Common\Service\Lpa\LpaService; use Common\Service\Security\RateLimitServiceFactory; use Mezzio\Helper\UrlHelper; @@ -21,7 +22,8 @@ public function __invoke(ContainerInterface $container) $container->get(TemplateRendererInterface::class), $container->get(UrlHelper::class), $container->get(LpaService::class), - $rateLimitFactory->factory('viewer_code_failure') + $rateLimitFactory->factory('viewer_code_failure'), + $container->get(FeatureEnabled::class), ); } } diff --git a/service-front/app/src/Viewer/src/Handler/ViewLpaHandler.php b/service-front/app/src/Viewer/src/Handler/ViewLpaHandler.php index 98692175a6..9a3b30dd36 100644 --- a/service-front/app/src/Viewer/src/Handler/ViewLpaHandler.php +++ b/service-front/app/src/Viewer/src/Handler/ViewLpaHandler.php @@ -36,7 +36,7 @@ public function __construct( } /** - * @param ServerRequestInterface $request + * @param ServerRequestInterface $request * @return ResponseInterface * @throws \Exception */ @@ -86,6 +86,11 @@ public function handle(ServerRequestInterface $request): ResponseInterface } } - return new HtmlResponse($this->renderer->render('viewer::view-lpa', $renderData)); + $templateName = 'viewer::view-lpa'; + if (($this->featureEnabled)('support_datastore_lpas')) { + $templateName = 'viewer::view-lpa-combined-lpa'; + } + + return new HtmlResponse($this->renderer->render($templateName, $renderData)); } } diff --git a/service-front/app/src/Viewer/templates/viewer/check-code-found-combined-lpa.html.twig b/service-front/app/src/Viewer/templates/viewer/check-code-found-combined-lpa.html.twig new file mode 100644 index 0000000000..2f1a13348c --- /dev/null +++ b/service-front/app/src/Viewer/templates/viewer/check-code-found-combined-lpa.html.twig @@ -0,0 +1,83 @@ +{% extends '@viewer/layout.html.twig' %} + +{% block html_title %}{% trans %}We’ve found this LPA{% endtrans %} - {{ parent() }} {% endblock %} + +{% block content %} +
+
+ {% trans %}Back{% endtrans %} +
+ +
+ +
+
+ + {{ govuk_error_summary(form) }} + + {{ govuk_form_open(form) }} + +

{% trans with {'%firstname%': lpa.donor.firstname, '%surname%': lpa.donor.surname} %}We’ve found %firstname% %surname%'s LPA{% endtrans %}

+ + + + + + + + + + + +
{% trans %}Type of LPA{% endtrans %}{{ lpa.caseSubtype.propertyAndAffairs ? 'Property and finance' | trans : 'Health and welfare' | trans }}
{% trans %}Code expires{% endtrans %}{% trans count days_remaining_to_expiry(expires) with {'%date%': lpa_date(expires)} %}in %count% day, on %date%|in %count% days, on %date%{% endtrans %}
+ +
+ + + {% trans %}Warning{% endtrans %} + {% trans %}If this is not the right LPA, ask the donor or attorney to check the access code.{% endtrans %} + +
+ +
+ + + {% trans with {'%date%': lpa_date(expires)} %}If you need to see this LPA after %date%{% endtrans %} + + +
+

+ {% trans with {'%date%': lpa_date(expires)} %}You can see an online summary of this LPA until %date%. After this date, the access code will expire.{% endtrans %} +

+

{% trans %}Ask the donor or attorney for a new access code if your organisation:{% endtrans %} +

    +
  • {% trans %}needs more time to process this LPA{% endtrans %}
  • +
  • {% trans %}need to see this LPA at a later date{% endtrans %}
  • +
+

+
+
+ + {{ govuk_form_element(form.get('__csrf')) }} + + {{ govuk_form_element(form.get('organisation'), + { + 'label': 'Your organisation name' | trans, + 'hint': 'This will be displayed to the attorneys and donor on the LPA' | trans + } + ) }} + + + +

+ {% trans %}Try another access code{% endtrans %} +

+ + {{ govuk_form_close() }} + +
+
+ +
+
+{% endblock %} diff --git a/service-front/app/src/Viewer/templates/viewer/download-lpa-combined-lpa.html.twig b/service-front/app/src/Viewer/templates/viewer/download-lpa-combined-lpa.html.twig new file mode 100644 index 0000000000..8aae65f6ba --- /dev/null +++ b/service-front/app/src/Viewer/templates/viewer/download-lpa-combined-lpa.html.twig @@ -0,0 +1,15 @@ +{% extends '@viewer/layout.html.twig' %} + +{% set forDownload = true %} + +{% block html_title %}{% trans %}Download LPA{% endtrans %} - {{ parent() }} {% endblock %} + +{% block stylesheets %} + +{% endblock %} + +{% block content %} + {% include '@partials/full-lpa-display-combined-lpa.html.twig' %} +{% endblock %} diff --git a/service-front/app/src/Viewer/templates/viewer/view-lpa-combined-lpa.html.twig b/service-front/app/src/Viewer/templates/viewer/view-lpa-combined-lpa.html.twig new file mode 100644 index 0000000000..7ac7a07dc6 --- /dev/null +++ b/service-front/app/src/Viewer/templates/viewer/view-lpa-combined-lpa.html.twig @@ -0,0 +1,7 @@ +{% extends '@viewer/layout.html.twig' %} + +{% block html_title %}{% trans %}LPA summary{% endtrans %} - {{ parent() }} {% endblock %} + +{% block content %} + {% include '@partials/full-lpa-display-combined-lpa.html.twig' with {'forDownload': false} %} +{% endblock %} diff --git a/service-front/app/test/ActorTest/Handler/Factory/CheckLpaHandlerFactoryTest.php b/service-front/app/test/ActorTest/Handler/Factory/CheckLpaHandlerFactoryTest.php index 2079dae162..4521e6f096 100644 --- a/service-front/app/test/ActorTest/Handler/Factory/CheckLpaHandlerFactoryTest.php +++ b/service-front/app/test/ActorTest/Handler/Factory/CheckLpaHandlerFactoryTest.php @@ -4,6 +4,7 @@ namespace ActorTest\Handler\Factory; +use Common\Service\Features\FeatureEnabled; use PHPUnit\Framework\Attributes\Test; use Common\Service\Lpa\AddLpa; use Common\Service\Lpa\LpaService; @@ -58,6 +59,9 @@ public function it_creates_a_correctly_configured_instance(): void $containerProphecy ->get(AddLpa::class) ->willReturn($this->prophesize(AddLpa::class)->reveal()); + $containerProphecy + ->get(FeatureEnabled::class) + ->willReturn($this->prophesize(FeatureEnabled::class)->reveal()); $factory = new CheckLpaHandlerFactory(); diff --git a/service-front/app/test/CommonTest/Entity/Casters/CastToHowAttorneysMakeDecisionsTest.php b/service-front/app/test/CommonTest/Entity/Casters/CastToHowAttorneysMakeDecisionsTest.php new file mode 100644 index 0000000000..c77a914aaa --- /dev/null +++ b/service-front/app/test/CommonTest/Entity/Casters/CastToHowAttorneysMakeDecisionsTest.php @@ -0,0 +1,56 @@ +assertEquals( + $howMakeDecision, + $castToHowAttorneysMakeDecisions->cast( + $howMakeDecision, + $this->prophesize(ObjectMapper::class)->reveal() + ) + ); + } + + public function howAttorneysMakeDecisionsProvider(): array + { + return [ + ['singular'], + ['jointly'], + ['jointly-and-severally'], + ['jointly-for-some-severally-for-others'], + ]; + } + + #[Test] + public function throws_exception_on_invalid_type() + { + $castToHowAttorneysMakeDecisions = new CastToHowAttorneysMakeDecisions(); + + $this->expectException(ValueError::class); + + $castToHowAttorneysMakeDecisions->cast( + 'not-a-valid-type', + $this->prophesize(ObjectMapper::class)->reveal() + ); + } +} diff --git a/service-front/app/test/CommonTest/Entity/Casters/CastToLifeSustainingTreatmentTest.php b/service-front/app/test/CommonTest/Entity/Casters/CastToLifeSustainingTreatmentTest.php index 2eb7cbbfdf..1ada461d88 100644 --- a/service-front/app/test/CommonTest/Entity/Casters/CastToLifeSustainingTreatmentTest.php +++ b/service-front/app/test/CommonTest/Entity/Casters/CastToLifeSustainingTreatmentTest.php @@ -6,29 +6,57 @@ use Common\Entity\Casters\CastToLifeSustainingTreatment; use EventSauce\ObjectHydrator\ObjectMapper; +use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; +use ValueError; class CastToLifeSustainingTreatmentTest extends TestCase { + use ProphecyTrait; + private ObjectMapper $mockHydrator; - private CastToLifeSustainingTreatment $castToLifeSustainingTreatment; + private CastToLifeSustainingTreatment $caster; public function setUp(): void { - $this->mockHydrator = $this->createMock(ObjectMapper::class); - $this->castToLifeSustainingTreatment = new CastToLifeSustainingTreatment(); + $this->mockHydrator = $this->createMock(ObjectMapper::class); + $this->caster = new CastToLifeSustainingTreatment(); } #[Test] - public function can_cast_life_sustaining_treatment(): void + #[DataProvider('lifeSustainingTreatmentProvider')] + public function can_cast_life_sustaining_treatment($input, $expectedOutput): void { - $lifeSustainingTreatment = 'option-a'; + $this->assertEquals( + $expectedOutput, + $this->caster->cast( + $input, + $this->prophesize(ObjectMapper::class)->reveal() + ) + ); + } - $expectedLifeSustainingTreatment = 'option-a'; + public function lifeSustainingTreatmentProvider(): array + { + return [ + ['Option A', 'option-a'], + ['option-a', 'option-a'], + ['Option B', 'option-b'], + ['option-b', 'option-b'], + ]; + } - $result = $this->castToLifeSustainingTreatment->cast($lifeSustainingTreatment, $this->mockHydrator); + #[Test] + public function throws_exception_on_invalid_type() + { + $this->expectException(InvalidArgumentException::class); - $this->assertEquals($expectedLifeSustainingTreatment, $result); + $this->caster->cast( + 'not-a-valid-type', + $this->prophesize(ObjectMapper::class)->reveal() + ); } } diff --git a/service-front/app/test/CommonTest/Entity/Casters/CastToWhenTheLpaCanBeUsedTest.php b/service-front/app/test/CommonTest/Entity/Casters/CastToWhenTheLpaCanBeUsedTest.php index 1d2bddc14d..d534fc7f3d 100644 --- a/service-front/app/test/CommonTest/Entity/Casters/CastToWhenTheLpaCanBeUsedTest.php +++ b/service-front/app/test/CommonTest/Entity/Casters/CastToWhenTheLpaCanBeUsedTest.php @@ -4,31 +4,56 @@ namespace CommonTest\Entity\Casters; +use Common\Entity\Casters\CastToHowAttorneysMakeDecisions; use Common\Entity\Casters\CastToWhenTheLpaCanBeUsed; use EventSauce\ObjectHydrator\ObjectMapper; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; +use ValueError; class CastToWhenTheLpaCanBeUsedTest extends TestCase { - private ObjectMapper $mockHydrator; - private CastToWhenTheLpaCanBeUsed $castToWhenTheLpaCanBeUsed; + use ProphecyTrait; - public function setUp(): void + #[Test] + #[DataProvider('whenCanTheLpaBeUsedProvider')] + public function can_cast_how_attorneys_make_decisions($input, $expectedOutput): void { - $this->mockHydrator = $this->createMock(ObjectMapper::class); - $this->castToWhenTheLpaCanBeUsed = new CastToWhenTheLpaCanBeUsed(); + $castToWhenTheLpaCanBeUsed = new CastToWhenTheLpaCanBeUsed(); + + $this->assertEquals( + $expectedOutput, + $castToWhenTheLpaCanBeUsed->cast( + $input, + $this->prophesize(ObjectMapper::class)->reveal() + ) + ); } - #[Test] - public function can_when_lpa_can_be_used(): void + public function whenCanTheLpaBeUsedProvider(): array { - $whenTheLpaCanBeUsed = 'singular'; + return [ + ['when registered', 'when-has-capacity'], + ['when-has-capacity', 'when-has-capacity'], + ['loss of capacity', 'when-capacity-lost'], + ['when-capacity-lost', 'when-capacity-lost'], + ['', ''], + ['unexpected', ''], + ]; + } - $expectedWhenTheLpaCanBeUsed = 'singular'; + #[Test] + public function throws_exception_on_invalid_type() + { + $castToHowAttorneysMakeDecisions = new CastToHowAttorneysMakeDecisions(); - $result = $this->castToWhenTheLpaCanBeUsed->cast($whenTheLpaCanBeUsed, $this->mockHydrator); + $this->expectException(ValueError::class); - $this->assertEquals($expectedWhenTheLpaCanBeUsed, $result); + $castToHowAttorneysMakeDecisions->cast( + 'not-a-valid-type', + $this->prophesize(ObjectMapper::class)->reveal() + ); } } diff --git a/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php b/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php index f59b984ce1..e9ea961064 100644 --- a/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php +++ b/service-front/app/test/CommonTest/Entity/CombinedLpaTest.php @@ -4,7 +4,13 @@ namespace CommonTest\Entity; +use Common\Enum\HowAttorneysMakeDecisions; +use Common\Enum\LifeSustainingTreatment; +use Common\Enum\LpaType; +use Common\Enum\WhenTheLpaCanBeUsed; use Common\Service\Lpa\Factory\LpaDataFormatter; +use CommonTest\Helper\EntityTestHelper; +use CommonTest\Helper\TestData; use DateTimeImmutable; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; @@ -24,15 +30,51 @@ public function setUp(): void #[Test] public function can_test_getters() { - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/test_lpa.json'), true); - $combinedLpa = ($this->lpaDataFormatter)($lpa); + $donor = EntityTestHelper::makePerson( + uId: 'donor' + ); - $expectedUid = '700000000047'; - $expectedApplicationHasGuidance = false; - $expectedHasRestrictions = false; + $attorneys = [ + EntityTestHelper::makePerson( + uId: 'attorney' + ), + ]; - $this->assertEquals($expectedUid, $combinedLpa->getUId()); - $this->assertEquals($expectedApplicationHasGuidance, $combinedLpa->getApplicationHasGuidance()); - $this->assertEquals($expectedHasRestrictions, $combinedLpa->getApplicationHasRestrictions()); + $trustCorporations = [ + EntityTestHelper::makePerson( + uId: 'trust-corporation' + ), + ]; + + $combinedLpa = EntityTestHelper::makeCombinedLpa( + applicationHasGuidance: true, + applicationHasRestrictions: true, + attorneys: $attorneys, + caseSubtype: LpaType::PERSONAL_WELFARE, + donor: $donor, + howAttorneysMakeDecisions: HowAttorneysMakeDecisions::JOINTLY, + lifeSustainingTreatment: LifeSustainingTreatment::OPTION_B, + lpaDonorSignatureDate: new DateTimeImmutable(TestData::TESTDATESTRING), + status: 'status', + trustCorporations: $trustCorporations, + uId: '123', + whenTheLpaCanBeUsed: WhenTheLpaCanBeUsed::WHEN_HAS_CAPACITY + ); + + $this->assertEquals(true, $combinedLpa->getApplicationHasGuidance()); + $this->assertEquals(true, $combinedLpa->getApplicationHasRestrictions()); + $this->assertEquals($attorneys, $combinedLpa->getActiveAttorneys()); + $this->assertEquals($donor, $combinedLpa->getDonor()); + $this->assertEquals(HowAttorneysMakeDecisions::JOINTLY, $combinedLpa->getHowAttorneysMakeDecisions()); + $this->assertEquals(false, $combinedLpa->getCaseAttorneySingular()); + $this->assertEquals(true, $combinedLpa->getCaseAttorneyJointly()); + $this->assertEquals(false, $combinedLpa->getCaseAttorneyJointlyAndSeverally()); + $this->assertEquals(false, $combinedLpa->getCaseAttorneyJointlyAndJointlyAndSeverally()); + $this->assertEquals(LifeSustainingTreatment::OPTION_B->value, $combinedLpa->getLifeSustainingTreatment()); + $this->assertEquals(new DateTimeImmutable(TestData::TESTDATESTRING), $combinedLpa->getLpaDonorSignatureDate()); + $this->assertEquals('status', $combinedLpa->getStatus()); + $this->assertEquals($trustCorporations, $combinedLpa->getTrustCorporations()); + $this->assertEquals('123', $combinedLpa->getUId()); + $this->assertEquals(WhenTheLpaCanBeUsed::WHEN_HAS_CAPACITY, $combinedLpa->getWhenTheLpaCanBeUsed()); } } diff --git a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php b/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php new file mode 100644 index 0000000000..87977109c3 --- /dev/null +++ b/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToCombinedFormatTest.php @@ -0,0 +1,120 @@ +lpaDataFormatter = new LpaDataFormatter(); + } + + public function expectedLpaStore(): LpaStore + { + $donor = new LpaStoreDonor( + line1 : '74 Cloob Close', + line2 : null, + line3 : null, + country : 'GB', + county : null, + dob : new DateTimeImmutable('1970-01-24'), + email : 'nobody@not.a.real.domain', + firstname : null, + firstnames : 'Feeg', + name : null, + otherNames : null, + postcode : null, + surname : 'Bundlaaaa', + systemStatus : null, + town : 'Mahhhhhhhhhh', + type : null, + uId : 'eda719db-8880-4dda-8c5d-bb9ea12c236f' + ); + + $attorneys = [ + new LpaStoreAttorney( + line1 : '81 NighOnTimeWeBuiltIt Street', + line2 : null, + line3 : null, + country : 'GB', + county : null, + dob : new DateTimeImmutable('1982-07-24'), + email : null, + firstname : null, + firstnames : 'Herman', + name : null, + otherNames : null, + postcode : null, + surname : 'Seakrest', + systemStatus : 'active', + town : 'Mahhhhhhhhhh', + type : null, + uId : '9ac5cb7c-fc75-40c7-8e53-059f36dbbe3d' + ), + ]; + + $trustCorporations = [ + new LpaStoreTrustCorporations( + line1 : '103 Line 1', + line2 : null, + line3 : null, + companyName : 'Trust us Corp.', + country : 'GB', + county : null, + dob : null, + email : null, + firstname : null, + firstnames : null, + name : 'Trust us Corp.', + otherNames : null, + postcode : null, + surname : null, + systemStatus : 'active', + town : 'Town', + type : null, + uId : '1d95993a-ffbb-484c-b2fe-f4cca51801da', + ), + ]; + + return EntityTestHelper::makeLpaStoreLpa( + attorneys: $attorneys, + donor: $donor, + howAttorneysMakeDecisions: HowAttorneysMakeDecisions::JOINTLY, + lpaDonorSignatureDate: new DateTimeImmutable('2024-01-10 23:00:00'), + registrationDate: new DateTimeImmutable('2024-01-12'), + status: 'registered', + trustCorporations: $trustCorporations, + uId: 'M-789Q-P4DF-4UX3', + ); + } + + #[Test] + public function can_hydrate_lpa_store_to_modernise_format(): void + { + $lpa = json_decode(file_get_contents(__DIR__ . '../../../../../test/fixtures/4UX3.json'), true); + + $combinedLpaStore = ($this->lpaDataFormatter)($lpa); + + $this->assertIsObject($combinedLpaStore); + + $this->assertEquals($this->expectedLpaStore(), $combinedLpaStore); + } +} diff --git a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToModerniseFormatTest.php b/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToModerniseFormatTest.php deleted file mode 100644 index 25df2cb7ba..0000000000 --- a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateLpaStoreToModerniseFormatTest.php +++ /dev/null @@ -1,141 +0,0 @@ -featureEnabled = $this->prophesize(FeatureEnabled::class); - $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); - } - - public function expectedLpaStore(): LpaStore - { - return new LpaStore( - $applicationHasGuidance = null, - $applicationHasRestrictions = null, - $applicationType = null, - $attorneyActDecisions = HowAttorneysMakeDecisions::tryFrom('jointly'), - $attorneys = [ - new LpaStoreAttorney( - $addressLine1 = '81 NighOnTimeWeBuiltIt Street', - $addressLine2 = null, - $addressLine3 = null, - $country = 'GB', - $county = null, - $dob = new DateTimeImmutable('1982-07-24'), - $email = null, - $firstname = null, - $firstnames = 'Herman', - $name = null, - $otherNames = null, - $postcode = null, - $surname = 'Seakrest', - $systemStatus = 'active', - $town = 'Mahhhhhhhhhh', - $type = null, - $uId = '9ac5cb7c-fc75-40c7-8e53-059f36dbbe3d' - ), - ], - $caseSubtype = LpaType::fromShortName('personal-welfare'), - $channel = 'online', - $dispatchDate = null, - $donor = new LpaStoreDonor( - $addressLine1 = '74 Cloob Close', - $addressLine2 = null, - $addressLine3 = null, - $country = 'GB', - $county = null, - $dob = new DateTimeImmutable('1970-01-24'), - $email = 'nobody@not.a.real.domain', - $firstname = null, - $firstnames = 'Feeg', - $name = null, - $otherNames = null, - $postcode = null, - $surname = 'Bundlaaaa', - $systemStatus = null, - $town = 'Mahhhhhhhhhh', - $type = null, - $uId = 'eda719db-8880-4dda-8c5d-bb9ea12c236f' - ), - $hasSeveranceWarning = null, - $invalidDate = null, - $lifeSustainingTreatment = LifeSustainingTreatment::fromShortName('Option A'), - $lpaDonorSignatureDate = new DateTimeImmutable('2024-01-10T23:00:00Z'), - $lpaIsCleansed = null, - $onlineLpaId = null, - $receiptDate = null, - $registrationDate = new DateTimeImmutable('2024-01-12'), - $rejectedDate = null, - $replacementAttorneys = null, - $status = 'registered', - $statusDate = null, - $trustCorporations = [ - new LpaStoreTrustCorporations( - $addressLine1 = '103 Line 1', - $addressLine2 = null, - $addressLine3 = null, - $companyName = 'Trust us Corp.', - $country = 'GB', - $county = null, - $dob = null, - $email = null, - $firstname = null, - $firstnames = null, - $name = 'Trust us Corp.', - $otherNames = null, - $postcode = null, - $surname = null, - $systemStatus = 'active', - $town = 'Town', - $type = null, - $uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da', - ), - ], - $uId = 'M-789Q-P4DF-4UX3', - $withdrawnDate = null - ); - } - - #[Test] - public function can_hydrate_lpa_store_to_modernise_format(): void - { - $this->featureEnabled - ->__invoke('support_datastore_lpas') - ->willReturn(true); - - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../../test/fixtures/4UX3.json'), true); - - $expectedLpaStore = $this->expectedLpaStore(); - - $combinedLpaStore = ($this->lpaDataFormatter)($lpa); - - $this->assertIsObject($combinedLpaStore); - - $this->assertEquals($expectedLpaStore, $combinedLpaStore); - } -} diff --git a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateSiriusToModerniseFormatTest.php b/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateSiriusToModerniseFormatTest.php deleted file mode 100644 index 75626ed2cd..0000000000 --- a/service-front/app/test/CommonTest/Entity/LpaStore/CanHydrateSiriusToModerniseFormatTest.php +++ /dev/null @@ -1,164 +0,0 @@ -featureEnabled = $this->prophesize(FeatureEnabled::class); - $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); - } - - public function expectedSiriusLpa(): SiriusLpa - { - return new SiriusLpa( - $applicationHasGuidance = false, - $applicationHasRestrictions = false, - $applicationType = 'Classic', - $attorneyActDecisions = null, - $attorneys = [ - new SiriusLpaAttorney( - $addressLine1 = '9 high street', - $addressLine2 = '', - $addressLine3 = '', - $country = '', - $county = '', - $dob = new DateTimeImmutable('1990-05-04'), - $email = '', - $firstname = 'jean', - $firstnames = null, - $name = null, - $otherNames = null, - $postcode = 'DN37 5SH', - $surname = 'sanderson', - $systemStatus = '1', - $town = '', - $type = 'Primary', - $uId = '700000000815' - ), - new SiriusLpaAttorney( - $addressLine1 = '', - $addressLine2 = '', - $addressLine3 = '', - $country = '', - $county = '', - $dob = new DateTimeImmutable('1975-10-05'), - $email = 'XXXXX', - $firstname = 'Ann', - $firstnames = null, - $name = null, - $otherNames = null, - $postcode = '', - $surname = 'Summers', - $systemStatus = '1', - $town = '', - $type = 'Primary', - $uId = '7000-0000-0849' - ), - ], - $caseSubtype = LpaType::fromShortName('personal-welfare'), - $channel = null, - $dispatchDate = null, - $donor = new SiriusLpaDonor( - $addressLine1 = '81 Front Street', - $addressLine2 = 'LACEBY', - $addressLine3 = '', - $country = '', - $county = '', - $dob = new DateTimeImmutable('1948-11-01'), - $email = 'RachelSanderson@opgtest.com', - $firstname = 'Rachel', - $firstnames = null, - $linked = [ - [ - 'id' => 7, - 'uId' => '700000000799', - ], - ], - $name = null, - $otherNames = null, - $postcode = 'DN37 5SH', - $surname = 'Sanderson', - $systemStatus = null, - $town = '', - $type = 'Primary', - $uId = '700000000799' - ), - $hasSeveranceWarning = null, - $invalidDate = null, - $lifeSustainingTreatment = LifeSustainingTreatment::fromShortName('Option A'), - $lpaDonorSignatureDate = new DateTimeImmutable('2012-12-12'), - $lpaIsCleansed = true, - $onlineLpaId = 'A33718377316', - $receiptDate = new DateTimeImmutable('2014-09-26'), - $registrationDate = new DateTimeImmutable('2019-10-10'), - $rejectedDate = null, - $replacementAttorneys = [], - $status = 'Registered', - $statusDate = null, - $trustCorporations = [ - new SiriusLpaTrustCorporations( - $addressLine1 = 'Street 1', - $addressLine2 = 'Street 2', - $addressLine3 = 'Street 3', - $country = 'GB', - $county = 'County', - $dob = null, - $email = null, - $firstname = 'trust', - $firstnames = null, - $name = null, - $otherNames = null, - $postcode = 'ABC 123', - $surname = 'test', - $systemStatus = '1', - $town = 'Town', - $type = 'Primary', - $uId = '7000-0015-1998', - ), - ], - $uId = '700000000047', - $withdrawnDate = null - ); - } - - #[Test] - public function can_hydrate_sirius_lpa_to_modernise_format(): void - { - $this->featureEnabled - ->__invoke('support_datastore_lpas') - ->willReturn(true); - - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../../test/fixtures/test_lpa.json'), true); - - $expectedSiriusLpa = $this->expectedSiriusLpa(); - - $combinedSiriusLpa = ($this->lpaDataFormatter)($lpa); - - $this->assertIsObject($combinedSiriusLpa); - - $this->assertEquals($expectedSiriusLpa, $combinedSiriusLpa); - } -} diff --git a/service-front/app/test/CommonTest/Entity/LpaStore/CanSerialiseLpaStoreToModerniseFormatTest.php b/service-front/app/test/CommonTest/Entity/LpaStore/CanSerialiseLpaStoreToModerniseFormatTest.php deleted file mode 100644 index f6abffd471..0000000000 --- a/service-front/app/test/CommonTest/Entity/LpaStore/CanSerialiseLpaStoreToModerniseFormatTest.php +++ /dev/null @@ -1,132 +0,0 @@ -featureEnabled = $this->prophesize(FeatureEnabled::class); - $this->featureEnabled - ->__invoke('support_datastore_lpas') - ->willReturn(false); - $this->lpaDataFormatter = new LpaDataFormatter(); - } - - private function getExpectedLpa(): array - { - return [ - 'applicationHasGuidance' => null, - 'applicationHasRestrictions' => null, - 'applicationType' => null, - 'attorneyActDecisions' => 'jointly', - 'attorneys' => [ - [ - 'addressLine1' => '81 NighOnTimeWeBuiltIt Street', - 'addressLine2' => null, - 'addressLine3' => null, - 'country' => 'GB', - 'county' => null, - 'dob' => '1982-07-24 00:00:00.000000+0000', - 'email' => null, - 'firstname' => null, - 'firstnames' => 'Herman', - 'name' => null, - 'otherNames' => null, - 'postcode' => null, - 'surname' => 'Seakrest', - 'systemStatus' => 'active', - 'town' => 'Mahhhhhhhhhh', - 'type' => null, - 'uId' => '9ac5cb7c-fc75-40c7-8e53-059f36dbbe3d', - ], - ], - 'caseSubtype' => 'hw', - 'channel' => 'online', - 'dispatchDate' => null, - 'donor' => [ - 'addressLine1' => '74 Cloob Close', - 'addressLine2' => null, - 'addressLine3' => null, - 'country' => 'GB', - 'county' => null, - 'dob' => '1970-01-24 00:00:00.000000+0000', - 'email' => 'nobody@not.a.real.domain', - 'firstname' => null, - 'firstnames' => 'Feeg', - 'name' => null, - 'otherNames' => null, - 'postcode' => null, - 'surname' => 'Bundlaaaa', - 'systemStatus' => null, - 'town' => 'Mahhhhhhhhhh', - 'type' => null, - 'uId' => 'eda719db-8880-4dda-8c5d-bb9ea12c236f', - ], - 'hasSeveranceWarning' => null, - 'invalidDate' => null, - 'lifeSustainingTreatment' => 'option-a', - 'lpaDonorSignatureDate' => '2024-01-10 23:00:00.000000+0000', - 'lpaIsCleansed' => null, - 'onlineLpaId' => null, - 'receiptDate' => null, - 'registrationDate' => '2024-01-12 00:00:00.000000+0000', - 'rejectedDate' => null, - 'replacementAttorneys' => null, - 'status' => 'registered', - 'statusDate' => null, - 'trustCorporations' => [ - [ - 'addressLine1' => '103 Line 1', - 'addressLine2' => null, - 'addressLine3' => null, - 'country' => 'GB', - 'county' => null, - 'dob' => null, - 'email' => null, - 'firstname' => null, - 'firstnames' => null, - 'name' => 'Trust us Corp.', - 'otherNames' => null, - 'postcode' => null, - 'surname' => null, - 'systemStatus' => 'active', - 'town' => 'Town', - 'type' => null, - 'uId' => '1d95993a-ffbb-484c-b2fe-f4cca51801da', - 'companyName' => 'Trust us Corp.', - ], - ], - 'uId' => 'M-789Q-P4DF-4UX3', - 'withdrawnDate' => null, - ]; - } - - #[Test] - public function can_serialise_datastore_lpa_to_modernise_format(): void - { - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../../test/fixtures/4UX3.json'), true); - $expectedLpa = $this->getExpectedLpa(); - - $newLpa = ($this->lpaDataFormatter)($lpa); - - $jsonLpa = json_encode($newLpa); - $expectedJsonLpa = json_encode($expectedLpa); - - $this->assertEquals($expectedJsonLpa, $jsonLpa); - } -} diff --git a/service-front/app/test/CommonTest/Entity/LpaStore/CanSerialiseSiriusToModerniseFormatTest.php b/service-front/app/test/CommonTest/Entity/LpaStore/CanSerialiseSiriusToModerniseFormatTest.php deleted file mode 100644 index 9c4d9bc258..0000000000 --- a/service-front/app/test/CommonTest/Entity/LpaStore/CanSerialiseSiriusToModerniseFormatTest.php +++ /dev/null @@ -1,154 +0,0 @@ -featureEnabled = $this->prophesize(FeatureEnabled::class); - $this->lpaDataFormatter = new LpaDataFormatter(); - } - - private function getExpectedLpa(): array - { - return [ - 'applicationHasGuidance' => false, - 'applicationHasRestrictions' => false, - 'applicationType' => 'Classic', - 'attorneyActDecisions' => null, - 'attorneys' => [ - [ - 'addressLine1' => '9 high street', - 'addressLine2' => '', - 'addressLine3' => '', - 'country' => '', - 'county' => '', - 'dob' => '1990-05-04 00:00:00.000000+0000', - 'email' => '', - 'firstname' => 'jean', - 'firstnames' => null, - 'name' => null, - 'otherNames' => null, - 'postcode' => 'DN37 5SH', - 'surname' => 'sanderson', - 'systemStatus' => '1', - 'town' => '', - 'type' => 'Primary', - 'uId' => '700000000815', - ], - [ - 'addressLine1' => '', - 'addressLine2' => '', - 'addressLine3' => '', - 'country' => '', - 'county' => '', - 'dob' => '1975-10-05 00:00:00.000000+0000', - 'email' => 'XXXXX', - 'firstname' => 'Ann', - 'firstnames' => null, - 'name' => null, - 'otherNames' => null, - 'postcode' => '', - 'surname' => 'Summers', - 'systemStatus' => '1', - 'town' => '', - 'type' => 'Primary', - 'uId' => '7000-0000-0849', - ], - ], - 'caseSubtype' => 'hw', - 'channel' => null, - 'dispatchDate' => null, - 'donor' => [ - 'addressLine1' => '81 Front Street', - 'addressLine2' => 'LACEBY', - 'addressLine3' => '', - 'country' => '', - 'county' => '', - 'dob' => '1948-11-01 00:00:00.000000+0000', - 'email' => 'RachelSanderson@opgtest.com', - 'firstname' => 'Rachel', - 'firstnames' => null, - 'name' => null, - 'otherNames' => null, - 'postcode' => 'DN37 5SH', - 'surname' => 'Sanderson', - 'systemStatus' => null, - 'town' => '', - 'type' => 'Primary', - 'uId' => '700000000799', - 'linked' => [ - [ - 'id' => 7, - 'uId' => '700000000799', - ], - ], - ], - 'hasSeveranceWarning' => null, - 'invalidDate' => null, - 'lifeSustainingTreatment' => 'option-a', - 'lpaDonorSignatureDate' => '2012-12-12 00:00:00.000000+0000', - 'lpaIsCleansed' => true, - 'onlineLpaId' => 'A33718377316', - 'receiptDate' => '2014-09-26 00:00:00.000000+0000', - 'registrationDate' => '2019-10-10 00:00:00.000000+0000', - 'rejectedDate' => null, - 'replacementAttorneys' => [], - 'status' => 'Registered', - 'statusDate' => null, - 'trustCorporations' => [ - [ - 'addressLine1' => 'Street 1', - 'addressLine2' => 'Street 2', - 'addressLine3' => 'Street 3', - 'country' => 'GB', - 'county' => 'County', - 'dob' => null, - 'email' => null, - 'firstname' => 'trust', - 'firstnames' => null, - 'name' => null, - 'otherNames' => null, - 'postcode' => 'ABC 123', - 'surname' => 'test', - 'systemStatus' => '1', - 'town' => 'Town', - 'type' => 'Primary', - 'uId' => '7000-0015-1998', - ], - ], - 'uId' => '700000000047', - 'withdrawnDate' => null, - ]; - } - - #[Test] - public function can_serialise_sirius_lpa_to_modernise_format(): void - { - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../../test/fixtures/test_lpa.json'), true); - $expectedLpa = $this->getExpectedLpa(); - - $newLpa = ($this->lpaDataFormatter)($lpa); - - $jsonLpa = json_encode($newLpa); - $expectedJsonLpa = json_encode($expectedLpa); - - $this->assertEquals($expectedJsonLpa, $jsonLpa); - } -} diff --git a/service-front/app/test/CommonTest/Entity/PersonTest.php b/service-front/app/test/CommonTest/Entity/PersonTest.php index 93662c868b..e78f4c59ea 100644 --- a/service-front/app/test/CommonTest/Entity/PersonTest.php +++ b/service-front/app/test/CommonTest/Entity/PersonTest.php @@ -4,6 +4,8 @@ namespace CommonTest\Entity; +use Common\Entity\Address; +use CommonTest\Helper\EntityTestHelper; use Common\Service\Lpa\Factory\LpaDataFormatter; use DateTimeImmutable; use PHPUnit\Framework\Attributes\Test; @@ -39,4 +41,22 @@ public function can_test_getters() $this->assertEquals($expectedSurname, $combinedLpa->getDonor()->getSurname()); $this->assertEquals($expectedDob, $combinedLpa->getDonor()->getDob()); } + + #[Test] + public function wraps_address_in_array_for_compatability() + { + $this->assertEquals( + [ + (new Address()) + ->setAddressLine1('Address Line 1') + ->setAddressLine2('Address Line 2') + ->setAddressLine3('Address Line 3') + ->setTown('Town') + ->setPostcode('Postcode') + ->setCounty('County') + ->setCountry('Country'), + ], + EntityTestHelper::MakePerson()->getAddresses() + ); + } } diff --git a/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php b/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php new file mode 100644 index 0000000000..94174bb910 --- /dev/null +++ b/service-front/app/test/CommonTest/Entity/Sirius/CanHydrateSiriusToCombinedFormatTest.php @@ -0,0 +1,152 @@ +lpaDataFormatter = new LpaDataFormatter(); + } + + public function expectedSiriusLpa(): SiriusLpa + { + $donor = new SiriusLpaDonor( + addressLine1 : '81 Front Street', + addressLine2 : 'LACEBY', + addressLine3 : '', + country : '', + county : '', + dob : new DateTimeImmutable('1948-11-01'), + email : 'RachelSanderson@opgtest.com', + firstname : 'Rachel', + firstnames : null, + linked : [ + [ + 'id' => 7, + 'uId' => '700000000799', + ], + ], + name : null, + otherNames : null, + postcode : 'DN37 5SH', + surname : 'Sanderson', + systemStatus : null, + town : '', + type : 'Primary', + uId : '700000000799' + ); + + $attorneys = [ + new SiriusLpaAttorney( + addressLine1 : '9 high street', + addressLine2 : '', + addressLine3 : '', + country : '', + county : '', + dob : new DateTimeImmutable('1990-05-04'), + email : '', + firstname : 'jean', + firstnames : null, + name : null, + otherNames : null, + postcode : 'DN37 5SH', + surname : 'sanderson', + systemStatus : '1', + town : '', + type : 'Primary', + uId : '700000000815' + ), + new SiriusLpaAttorney( + addressLine1 : '', + addressLine2 : '', + addressLine3 : '', + country : '', + county : '', + dob : new DateTimeImmutable('1975-10-05'), + email : 'XXXXX', + firstname : 'Ann', + firstnames : null, + name : null, + otherNames : null, + postcode : '', + surname : 'Summers', + systemStatus : '1', + town : '', + type : 'Primary', + uId : '7000-0000-0849' + ), + ]; + + $trustCorporations = [ + new SiriusLpaTrustCorporations( + addressLine1 : 'Street 1', + addressLine2 : 'Street 2', + addressLine3 : 'Street 3', + country : 'GB', + county : 'County', + dob : null, + email : null, + firstname : 'trust', + firstnames : null, + name : null, + otherNames : null, + postcode : 'ABC 123', + surname : 'test', + systemStatus : '1', + town : 'Town', + type : 'Primary', + uId : '7000-0015-1998', + ), + ]; + + return EntityTestHelper::makeSiriusLpa( + attorneys: $attorneys, + channel: null, + donor: $donor, + howAttorneysMakeDecisions: HowAttorneysMakeDecisions::JOINTLY_AND_SEVERALLY, + lpaDonorSignatureDate: new DateTimeImmutable('2012-12-12'), + lpaIsCleansed: true, + onlineLpaId: 'A33718377316', + receiptDate: new DateTimeImmutable('2014-09-26'), + registrationDate: new DateTimeImmutable('2019-10-10'), + replacementAttorneys: [], + trustCorporations: $trustCorporations, + uId: '700000000047', + whenTheLpaCanBeUsed: WhenTheLpaCanBeUsed::WHEN_HAS_CAPACITY, + ); + } + + #[Test] + public function can_hydrate_sirius_lpa_to_modernise_format(): void + { + $lpa = json_decode(file_get_contents(__DIR__ . '../../../../../test/fixtures/test_lpa.json'), true); + + $expectedSiriusLpa = $this->expectedSiriusLpa(); + + $combinedSiriusLpa = ($this->lpaDataFormatter)($lpa); + + $this->assertIsObject($combinedSiriusLpa); + + $this->assertEquals($expectedSiriusLpa, $combinedSiriusLpa); + } +} diff --git a/service-front/app/test/CommonTest/Entity/Sirius/SiriusLpaTrustCorporationTest.php b/service-front/app/test/CommonTest/Entity/Sirius/SiriusLpaTrustCorporationTest.php new file mode 100644 index 0000000000..1dc9c3414d --- /dev/null +++ b/service-front/app/test/CommonTest/Entity/Sirius/SiriusLpaTrustCorporationTest.php @@ -0,0 +1,40 @@ +assertEquals( + 'name', + (new SiriusLpaTrustCorporations( + addressLine1: '', + addressLine2: '', + addressLine3: '', + country: '', + county: '', + dob: new DateTimeImmutable(), + email: '', + firstname: '', + firstnames: '', + name: 'name', + otherNames: '', + postcode: '', + surname: '', + systemStatus: '', + town: '', + type: '', + uId: '' + ))->getCompanyName() + ); + } +} diff --git a/service-front/app/test/CommonTest/Enum/HowAttorneysMakeDecisionsTest.php b/service-front/app/test/CommonTest/Enum/HowAttorneysMakeDecisionsTest.php new file mode 100644 index 0000000000..250af4cd9c --- /dev/null +++ b/service-front/app/test/CommonTest/Enum/HowAttorneysMakeDecisionsTest.php @@ -0,0 +1,33 @@ +assertTrue($singular->isSingular()); + $this->assertFalse($singular->isJointly()); + + $this->assertTrue($jointly->isJointly()); + $this->assertFalse($jointly->isSingular()); + + $this->assertTrue($jointlyAndSeverally->isJointlyAndSeverally()); + $this->assertFalse($jointlyAndSeverally->isSingular()); + + $this->assertTrue($jointlyForSome->isJointlyForSomeSeverallyForOthers()); + $this->assertFalse($jointlyForSome->isSingular()); + } +} diff --git a/service-front/app/test/CommonTest/Enum/LifeSustainingTreatmentTest.php b/service-front/app/test/CommonTest/Enum/LifeSustainingTreatmentTest.php new file mode 100644 index 0000000000..2806704c10 --- /dev/null +++ b/service-front/app/test/CommonTest/Enum/LifeSustainingTreatmentTest.php @@ -0,0 +1,25 @@ +assertTrue($optionA->isOptionA()); + $this->assertFalse($optionA->isOptionB()); + + $this->assertTrue($optionB->isOptionB()); + $this->assertFalse($optionB->isOptionA()); + } +} diff --git a/service-front/app/test/CommonTest/Enum/LpaTypeTest.php b/service-front/app/test/CommonTest/Enum/LpaTypeTest.php new file mode 100644 index 0000000000..fae54bf312 --- /dev/null +++ b/service-front/app/test/CommonTest/Enum/LpaTypeTest.php @@ -0,0 +1,25 @@ +assertTrue($propertyAndAffairs->isPropertyAndAffairs()); + $this->assertFalse($propertyAndAffairs->isPersonalWelfare()); + + $this->assertTrue($personalWelfare->isPersonalWelfare()); + $this->assertFalse($personalWelfare->isPropertyAndAffairs()); + } +} diff --git a/service-front/app/test/CommonTest/Enum/WhenCanTheLpaBeUsedTest.php b/service-front/app/test/CommonTest/Enum/WhenCanTheLpaBeUsedTest.php new file mode 100644 index 0000000000..86e16cfa57 --- /dev/null +++ b/service-front/app/test/CommonTest/Enum/WhenCanTheLpaBeUsedTest.php @@ -0,0 +1,29 @@ +assertTrue($whenHasCapacity->isWhenHasCapacity()); + $this->assertFalse($whenHasCapacity->isUnknown()); + + $this->assertTrue($whenCapacityLost->isWhenCapacityLost()); + $this->assertFalse($whenCapacityLost->isUnknown()); + + $this->assertTrue($unknown->isUnknown()); + $this->assertFalse($unknown->isWhenCapacityLost()); + } +} diff --git a/service-front/app/test/CommonTest/Helper/EntityTestHelper.php b/service-front/app/test/CommonTest/Helper/EntityTestHelper.php new file mode 100644 index 0000000000..a24f22da85 --- /dev/null +++ b/service-front/app/test/CommonTest/Helper/EntityTestHelper.php @@ -0,0 +1,251 @@ +getMockedCombinedFormat(); + $combinedFormat = ParseLpaData::getMockedCombinedFormat(false); $this->lpaFactory->createLpaFromData($this->lpaData['lpa'])->willReturn($combinedFormat); $this->lpaFactory->createCaseActorFromData($this->lpaData['actor']['details'])->willReturn($this->actor); $this->instAndPrefImagesFactory->createFromData($this->lpaData['iap'])->willReturn($this->iapImages); @@ -144,281 +148,106 @@ public function it_correctly_parses_an_combined_lpa_api_response(): void ->willReturn(true); $this->lpaData['lpa'] = $combinedFormat; - $result = $sut( - $this->lpaData - ); + $result = $sut($this->lpaData); $this->assertEquals($this->expectedSiriusLpa(), $result->lpa); } - private function getMockedCombinedFormat(): array - { - return [ - 'id' => 2, - 'uId' => '700000000047', - 'receiptDate' => '2014-09-26', - 'registrationDate' => '2019-10-10', - 'rejectedDate' => null, - 'donor' => [ - 'id' => 7, - 'uId' => '700000000799', - 'linked' => [['id' => 7, 'uId' => '700000000799']], - 'dob' => '1948-11-01', - 'email' => 'RachelSanderson@opgtest.com', - 'salutation' => 'Mr', - 'firstname' => 'Rachel', - 'middlenames' => 'Emma', - 'surname' => 'Sanderson', - 'addresses' => [ - [ - 'id' => 7, - 'town' => '', - 'county' => '', - 'postcode' => 'DN37 5SH', - 'country' => '', - 'type' => 'Primary', - 'addressLine1' => '81 Front Street', - 'addressLine2' => 'LACEBY', - 'addressLine3' => '', - ], - ], - 'companyName' => null, - ], - 'applicationType' => 'Classic', - 'caseSubtype' => 'hw', - 'status' => 'Registered', - 'lpaIsCleansed' => true, - 'caseAttorneySingular' => false, - 'caseAttorneyJointlyAndSeverally' => true, - 'caseAttorneyJointly' => false, - 'caseAttorneyJointlyAndJointlyAndSeverally' => false, - 'onlineLpaId' => 'A33718377316', - 'cancellationDate' => null, - 'attorneys' => [ - [ - 'id' => 9, - 'uId' => '700000000815', - 'dob' => '1990-05-04', - 'email' => '', - 'salutation' => '', - 'firstname' => 'jean', - 'middlenames' => '', - 'surname' => 'sanderson', - 'addresses' => [ - [ - 'id' => 9, - 'town' => '', - 'county' => '', - 'postcode' => 'DN37 5SH', - 'country' => '', - 'type' => 'Primary', - 'addressLine1' => '9 high street', - 'addressLine2' => '', - 'addressLine3' => '', - ], - ], - 'systemStatus' => true, - 'companyName' => '', - ], - [ - 'id' => 12, - 'uId' => '7000-0000-0849', - 'dob' => '1975-10-05', - 'email' => 'XXXXX', - 'salutation' => 'Mrs', - 'firstname' => 'Ann', - 'middlenames' => '', - 'surname' => 'Summers', - 'addresses' => [ - [ - 'id' => 12, - 'town' => '', - 'county' => '', - 'postcode' => '', - 'country' => '', - 'type' => 'Primary', - 'addressLine1' => '', - 'addressLine2' => '', - 'addressLine3' => '', - ], - ], - 'systemStatus' => true, - 'companyName' => '', - ], - ], - 'replacementAttorneys' => [], - 'trustCorporations' => [ - [ - 'addresses' => [ - [ - 'id' => 3207, - 'town' => 'Town', - 'county' => 'County', - 'postcode' => 'ABC 123', - 'country' => 'GB', - 'type' => 'Primary', - 'addressLine1' => 'Street 1', - 'addressLine2' => 'Street 2', - 'addressLine3' => 'Street 3', - ], - ], - 'id' => 3485, - 'uId' => '7000-0015-1998', - 'dob' => null, - 'email' => null, - 'salutation' => null, - 'firstname' => 'trust', - 'middlenames' => null, - 'surname' => 'test', - 'otherNames' => null, - 'systemStatus' => true, - 'companyName' => 'trust corporation', - ], - ], - 'certificateProviders' => [ - [ - 'id' => 11, - 'uId' => '7000-0000-0831', - 'dob' => null, - 'email' => null, - 'salutation' => 'Miss', - 'firstname' => 'Danielle', - 'middlenames' => null, - 'surname' => 'Hart ', - 'addresses' => [ - [ - 'id' => 11, - 'town' => '', - 'county' => '', - 'postcode' => 'SK14 0RH', - 'country' => '', - 'type' => 'Primary', - 'addressLine1' => '50 Fordham Rd', - 'addressLine2' => 'HADFIELD', - 'addressLine3' => '', - ], - ], - ], - ], - 'attorneyActDecisions' => null, - 'applicationHasRestrictions' => false, - 'applicationHasGuidance' => false, - 'lpaDonorSignatureDate' => '2012-12-12', - 'lifeSustainingTreatment' => 'Option A', - ]; - } - public function expectedSiriusLpa(): SiriusLpa { - return new SiriusLpa( - applicationHasGuidance: false, - applicationHasRestrictions: false, - applicationType : 'Classic', - attorneyActDecisions : null, - attorneys: [ - new SiriusLpaAttorney( - addressLine1 : '9 high street', - addressLine2 : '', - addressLine3 : '', - country : '', - county : '', - dob : new DateTimeImmutable('1990-05-04'), - email : '', - firstname : 'jean', - firstnames : null, - name : null, - otherNames : null, - postcode : 'DN37 5SH', - surname : 'sanderson', - systemStatus : '1', - town : '', - type : 'Primary', - uId : '700000000815' - ), - new SiriusLpaAttorney( - addressLine1 : '', - addressLine2 : '', - addressLine3 : '', - country : '', - county : '', - dob : new DateTimeImmutable('1975-10-05'), - email : 'XXXXX', - firstname : 'Ann', - firstnames : null, - name : null, - otherNames : null, - postcode : '', - surname : 'Summers', - systemStatus : '1', - town : '', - type : 'Primary', - uId : '7000-0000-0849' - ), - ], - caseSubtype : LpaType::fromShortName('personal-welfare'), - channel : null, - dispatchDate : null, - donor : new SiriusLpaDonor( - addressLine1 : '81 Front Street', - addressLine2 : 'LACEBY', + $attorneys = [ + new SiriusLpaAttorney( + addressLine1 : '9 high street', + addressLine2 : '', addressLine3 : '', country : '', county : '', - dob : new DateTimeImmutable('1948-11-01'), - email : 'RachelSanderson@opgtest.com', - firstname : 'Rachel', + dob : new DateTimeImmutable('1990-05-04'), + email : '', + firstname : 'jean', firstnames : null, - linked : [ - [ - 'id' => 7, - 'uId' => '700000000799', - ], - ], name : null, otherNames : null, postcode : 'DN37 5SH', - surname : 'Sanderson', - systemStatus : null, + surname : 'sanderson', + systemStatus : '1', town : '', type : 'Primary', - uId : '700000000799' + uId : '700000000815' ), - hasSeveranceWarning : null, - invalidDate : null, - lifeSustainingTreatment : LifeSustainingTreatment::fromShortName('Option A'), - lpaDonorSignatureDate : new DateTimeImmutable('2012-12-12'), - lpaIsCleansed : true, - onlineLpaId : 'A33718377316', - receiptDate : new DateTimeImmutable('2014-09-26'), - registrationDate : new DateTimeImmutable('2019-10-10'), - rejectedDate : null, - replacementAttorneys : [], - status : 'Registered', - statusDate : null, - trustCorporations : [ - new SiriusLpaTrustCorporations( - addressLine1 : 'Street 1', - addressLine2 : 'Street 2', - addressLine3 : 'Street 3', - country : 'GB', - county : 'County', - dob : null, - email : null, - firstname : 'trust', - firstnames : null, - name : null, - otherNames : null, - postcode : 'ABC 123', - surname : 'test', - systemStatus : '1', - town : 'Town', - type : 'Primary', - uId : '7000-0015-1998', - ), - ], - uId : '700000000047', - withdrawnDate : null + new SiriusLpaAttorney( + addressLine1 : '', + addressLine2 : '', + addressLine3 : '', + country : '', + county : '', + dob : new DateTimeImmutable('1975-10-05'), + email : 'XXXXX', + firstname : 'Ann', + firstnames : null, + name : null, + otherNames : null, + postcode : '', + surname : 'Summers', + systemStatus : '1', + town : '', + type : 'Primary', + uId : '7000-0000-0849' + ), + ]; + + $donor = new SiriusLpaDonor( + addressLine1 : '81 Front Street', + addressLine2 : 'LACEBY', + addressLine3 : '', + country : '', + county : '', + dob : new DateTimeImmutable('1948-11-01'), + email : 'RachelSanderson@opgtest.com', + firstname : 'Rachel', + firstnames : null, + linked : [ + [ + 'id' => 7, + 'uId' => '700000000799', + ], + ], + name : null, + otherNames : null, + postcode : 'DN37 5SH', + surname : 'Sanderson', + systemStatus : null, + town : '', + type : 'Primary', + uId : '700000000799' ); - } + $trustCorporations = [ + new SiriusLpaTrustCorporations( + addressLine1 : 'Street 1', + addressLine2 : 'Street 2', + addressLine3 : 'Street 3', + country : 'GB', + county : 'County', + dob : null, + email : null, + firstname : 'trust', + firstnames : null, + name : null, + otherNames : null, + postcode : 'ABC 123', + surname : 'test', + systemStatus : '1', + town : 'Town', + type : 'Primary', + uId : '7000-0015-1998', + ), + ]; + + return EntityTestHelper::makeSiriusLpa( + attorneys: $attorneys, + donor: $donor, + trustCorporations: $trustCorporations, + ); + } } diff --git a/service-front/app/test/ViewerTest/Handler/Factory/CheckCodeHandlerFactoryTest.php b/service-front/app/test/ViewerTest/Handler/Factory/CheckCodeHandlerFactoryTest.php index deaef86d1e..ed978394b6 100644 --- a/service-front/app/test/ViewerTest/Handler/Factory/CheckCodeHandlerFactoryTest.php +++ b/service-front/app/test/ViewerTest/Handler/Factory/CheckCodeHandlerFactoryTest.php @@ -4,6 +4,7 @@ namespace ViewerTest\Handler\Factory; +use Common\Service\Features\FeatureEnabled; use PHPUnit\Framework\Attributes\Test; use Common\Service\Lpa\LpaService; use Common\Service\Security\RateLimitService; @@ -42,6 +43,9 @@ public function it_creates_a_correctly_configured_instance(): void $containerProphecy ->get(RateLimitServiceFactory::class) ->willReturn($rlsfProphecy->reveal()); + $containerProphecy + ->get(FeatureEnabled::class) + ->willReturn($this->prophesize(FeatureEnabled::class)->reveal()); $factory = new CheckCodeHandlerFactory(); diff --git a/service-front/app/test/fixtures/test_lpa.json b/service-front/app/test/fixtures/test_lpa.json index 1951acbfca..9b42662b1b 100644 --- a/service-front/app/test/fixtures/test_lpa.json +++ b/service-front/app/test/fixtures/test_lpa.json @@ -154,5 +154,7 @@ "applicationHasRestrictions": false, "applicationHasGuidance": false, "lpaDonorSignatureDate": "2012-12-12", - "lifeSustainingTreatment": "Option A" + "lifeSustainingTreatment": "Option A", + "whenTheLpaCanBeUsed": "when registered", + "howAttorneysMakeDecisions": "jointly-and-severally" }