From f134454f867c75c22aaea189204f2241a6df0cd5 Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Mon, 30 Sep 2024 16:25:54 +0100 Subject: [PATCH 01/14] UML-3619 wip --- .../app/src/App/src/ConfigProvider.php | 2 +- .../src/DataAccess/ApiGateway/SiriusLpas.php | 28 +++++++++++-------- .../ApiGateway/SiriusLpasFactory.php | 6 +++- .../ApiGateway/SiriusLpasFactoryTest.php | 10 +++++++ .../DataAccess/ApiGateway/SiriusLpasTest.php | 15 +++++++++- .../DataAccess/ApiGateway/PactLpasFactory.php | 4 ++- 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/service-api/app/src/App/src/ConfigProvider.php b/service-api/app/src/App/src/ConfigProvider.php index daf0cfea0c..a8a414adb9 100644 --- a/service-api/app/src/App/src/ConfigProvider.php +++ b/service-api/app/src/App/src/ConfigProvider.php @@ -98,7 +98,7 @@ public function getDependencies(): array DataAccess\DynamoDb\ViewerCodeActivity::class => DataAccess\DynamoDb\ViewerCodeActivityFactory::class, DataAccess\DynamoDb\ViewerCodes::class => DataAccess\DynamoDb\ViewerCodesFactory::class, DataAccess\DynamoDb\UserLpaActorMap::class => DataAccess\DynamoDb\UserLpaActorMapFactory::class, - DataAccess\ApiGateway\SiriusLpas::class => DataAccess\ApiGateway\SiriusLpasFactory::class, + DataAccess\ApiGateway\SiriusLpas::class => DataAccess\ApiGateway\SiriusLpasFactory::class, DataAccess\ApiGateway\InstructionsAndPreferencesImages::class => DataAccess\ApiGateway\InstructionsAndPreferencesImagesFactory::class, diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php b/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php index c45d42f152..6ad5e5abf5 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php @@ -10,7 +10,9 @@ use App\DataAccess\Repository\Response\Lpa; use App\DataAccess\Repository\Response\LpaInterface; use App\Exception\ApiException; +use App\Service\Features\FeatureEnabled; use App\Service\Log\EventCodes; +use App\Service\Lpa\LpaDataFormatter; use App\Service\Lpa\SiriusLpa; use DateTimeImmutable; use Exception; @@ -45,6 +47,8 @@ public function __construct( string $traceId, private readonly DataSanitiserStrategy $sanitiser, private readonly LoggerInterface $logger, + private FeatureEnabled $featureEnabled, + private LpaDataFormatter $lpaDataFormatter, ) { parent::__construct( $httpClient, @@ -124,21 +128,23 @@ public function lookup(array $uids): array // Handle all request response now foreach ($results as $uid => $result) { $statusCode = $result->getStatusCode(); - + $response = json_decode( + $result->getBody()->getContents(), + true, + ); switch ($statusCode) { case 200: # TODO: We can some more error checking around this. - $results[$uid] = new Lpa( - new SiriusLpa( - $this->sanitiser->sanitise( - json_decode( - $result->getBody()->getContents(), - true - ), + if (($this->featureEnabled)('support_datastore_lpas')) { + $results[$uid] = ($this->lpaDataFormatter)($response); + } else { + $results[$uid] = new Lpa( + new SiriusLpa( + $this->sanitiser->sanitise($response), ), - ), - new DateTimeImmutable($result->getHeaderLine('Date')) - ); + new DateTimeImmutable($result->getHeaderLine('Date')) + ); + } break; default: $this->logger->warning( diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpasFactory.php b/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpasFactory.php index 21e96ce0c5..6bb5bdf223 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpasFactory.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpasFactory.php @@ -5,7 +5,9 @@ namespace App\DataAccess\ApiGateway; use App\DataAccess\ApiGateway\Sanitisers\SiriusLpaSanitiser; +use App\Service\Features\FeatureEnabled; use App\Service\Log\RequestTracing; +use App\Service\Lpa\LpaDataFormatter; use GuzzleHttp\Client; use Psr\Container\ContainerInterface; use Psr\Http\Client\ClientInterface; @@ -40,7 +42,9 @@ public function __invoke(ContainerInterface $container) $config['sirius_api']['endpoint'], $container->get(RequestTracing::TRACE_PARAMETER_NAME), $container->get(SiriusLpaSanitiser::class), - $container->get(LoggerInterface::class) + $container->get(LoggerInterface::class), + $container->get(FeatureEnabled::class), + $container->get(LpaDataFormatter::class), ); } } diff --git a/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasFactoryTest.php b/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasFactoryTest.php index 7ec915633d..342b590499 100644 --- a/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasFactoryTest.php +++ b/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasFactoryTest.php @@ -9,7 +9,9 @@ use App\DataAccess\ApiGateway\Sanitisers\SiriusLpaSanitiser; use App\DataAccess\ApiGateway\SiriusLpas; use App\DataAccess\ApiGateway\SiriusLpasFactory; +use App\Service\Features\FeatureEnabled; use App\Service\Log\RequestTracing; +use App\Service\Lpa\LpaDataFormatter; use Exception; use GuzzleHttp\Client as GuzzleHttpClient; use PHPUnit\Framework\Attributes\Test; @@ -70,6 +72,14 @@ public function can_instantiate(): void $this->prophesize(LoggerInterface::class)->reveal() ); + $containerProphecy->get(FeatureEnabled::class)->willReturn( + $this->prophesize(FeatureEnabled::class)->reveal() + ); + + $containerProphecy->get(LpaDataFormatter::class)->willReturn( + $this->prophesize(LpaDataFormatter::class)->reveal() + ); + $factory = new SiriusLpasFactory(); $repo = $factory($containerProphecy->reveal()); $this->assertInstanceOf(SiriusLpas::class, $repo); diff --git a/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasTest.php b/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasTest.php index 499955d7e8..1a00e300cd 100644 --- a/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasTest.php +++ b/service-api/app/test/AppTest/DataAccess/ApiGateway/SiriusLpasTest.php @@ -10,6 +10,8 @@ use App\DataAccess\Repository\DataSanitiserStrategy; use App\DataAccess\Repository\Response\LpaInterface; use App\Exception\ApiException; +use App\Service\Features\FeatureEnabled; +use App\Service\Lpa\LpaDataFormatter; use Fig\Http\Message\StatusCodeInterface; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Exception\GuzzleException; @@ -34,12 +36,17 @@ class SiriusLpasTest extends TestCase private DataSanitiserStrategy|ObjectProphecy $dataSanitiserStrategy; private LoggerInterface|ObjectProphecy $loggerInterface; private RequestSignerFactory|ObjectProphecy $requestSignerFactoryProphecy; + private FeatureEnabled|ObjectProphecy $featureEnabled; + private LpaDataFormatter|ObjectProphecy $lpaDataFormatter; public function setUp(): void { $this->guzzleClientProphecy = $this->prophesize(GuzzleClient::class); $this->dataSanitiserStrategy = $this->prophesize(DataSanitiserStrategy::class); $this->loggerInterface = $this->prophesize(LoggerInterface::class); + $this->featureEnabled = $this->prophesize(FeatureEnabled::class); + + $this->lpaDataFormatter = $this->prophesize(LpaDataFormatter::class); $requestSignerProphecy = $this->prophesize(RequestSigner::class); $requestSignerProphecy @@ -62,7 +69,9 @@ private function getLpas(): SiriusLpas 'localhost', 'test-trace-id', $this->dataSanitiserStrategy->reveal(), - $this->loggerInterface->reveal() + $this->loggerInterface->reveal(), + $this->featureEnabled->reveal(), + $this->lpaDataFormatter->reveal(), ); } @@ -97,6 +106,10 @@ public function can_get_an_lpa(): void $this->dataSanitiserStrategy->sanitise(Argument::any())->willReturnArgument(0); + $this->featureEnabled + ->__invoke('support_datastore_lpas') + ->willReturn(false); + $shouldBeAnLPA = $this->getLpas()->get('700000055554'); $this->assertInstanceOf(LpaInterface::class, $shouldBeAnLPA); diff --git a/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php b/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php index d553479c99..6be44a0991 100644 --- a/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php +++ b/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php @@ -8,6 +8,7 @@ use App\DataAccess\ApiGateway\RequestSignerFactory; use App\DataAccess\ApiGateway\Sanitisers\SiriusLpaSanitiser; use App\DataAccess\Repository\LpasInterface; +use App\Service\Features\FeatureEnabled; use App\Service\Log\RequestTracing; use DI\NotFoundException; use Exception; @@ -51,7 +52,8 @@ public function __invoke(ContainerInterface $container): LpasInterface parse_url($config['sirius_api']['endpoint'], PHP_URL_HOST), $container->get(RequestTracing::TRACE_PARAMETER_NAME), $container->get(SiriusLpaSanitiser::class), - $container->get(LoggerInterface::class) + $container->get(LoggerInterface::class), + $container->get(FeatureEnabled::class) ); } } From 4fc3d74c326a8c2fc8e3988723bf4abdd9587fd3 Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Mon, 30 Sep 2024 17:27:46 +0100 Subject: [PATCH 02/14] UML-3619 wip --- docker-compose.yml | 4 ++-- .../app/src/App/src/Service/Lpa/LpaDataFormatter.php | 4 +--- .../app/src/App/src/Service/Lpa/LpaManagerFactory.php | 6 +++--- .../BehatTest/DataAccess/ApiGateway/PactLpasFactory.php | 4 +++- service-api/app/test/fixtures/example_lpa.json | 4 ++-- service-front/app/test/fixtures/full_example.json | 4 ++-- .../app/test/fixtures/full_example_signed_before_2016.json | 4 ++-- service-front/app/test/fixtures/simple_example.json | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index fc333a8555..afbf84be39 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,7 +108,7 @@ services: ALLOW_MERIS_LPAS: "false" INSTRUCTIONS_AND_PREFERENCES: "true" ALLOW_GOV_ONE_LOGIN: "true" - SUPPORT_DATASTORE_LPAS: "false" + SUPPORT_DATASTORE_LPAS: "true" # Local only API_SERVICE_URL: @@ -195,7 +195,7 @@ services: ALLOW_MERIS_LPAS: "false" INSTRUCTIONS_AND_PREFERENCES: "true" ALLOW_GOV_ONE_LOGIN: "true" - SUPPORT_DATASTORE_LPAS: "false" + SUPPORT_DATASTORE_LPAS: "true" # Local only AWS_ACCESS_KEY_ID: "devkey" diff --git a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php index 633060bfa1..42f58bf84c 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php @@ -33,9 +33,7 @@ public function __invoke(array $lpa) { $lpaObject = $this->hydrateObject($lpa); - return $this->mapper->serializeObject( - $lpaObject - ); + return $lpaObject; } /** diff --git a/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php b/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php index f080ec8b44..7f98fd5a78 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php @@ -16,9 +16,9 @@ public function __construct(private readonly ContainerInterface $container) public function __invoke(): LpaManagerInterface { - if (($this->container->get(FeatureEnabled::class))('support_datastore_lpas')) { - throw new RuntimeException('Datastore LPA support is enabled but not implemented yet.'); - } +// if (($this->container->get(FeatureEnabled::class))('support_datastore_lpas')) { +// throw new RuntimeException('Datastore LPA support is enabled but not implemented yet.'); +// } return $this->container->get(SiriusLpaManager::class); } diff --git a/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php b/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php index 6be44a0991..ed0605453c 100644 --- a/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php +++ b/service-api/app/test/BehatTest/DataAccess/ApiGateway/PactLpasFactory.php @@ -10,6 +10,7 @@ use App\DataAccess\Repository\LpasInterface; use App\Service\Features\FeatureEnabled; use App\Service\Log\RequestTracing; +use App\Service\Lpa\LpaDataFormatter; use DI\NotFoundException; use Exception; use GuzzleHttp\Client; @@ -53,7 +54,8 @@ public function __invoke(ContainerInterface $container): LpasInterface $container->get(RequestTracing::TRACE_PARAMETER_NAME), $container->get(SiriusLpaSanitiser::class), $container->get(LoggerInterface::class), - $container->get(FeatureEnabled::class) + $container->get(FeatureEnabled::class), + $container->get(LpaDataFormatter::class) ); } } diff --git a/service-api/app/test/fixtures/example_lpa.json b/service-api/app/test/fixtures/example_lpa.json index 6b03b5feb6..c6b10036ed 100644 --- a/service-api/app/test/fixtures/example_lpa.json +++ b/service-api/app/test/fixtures/example_lpa.json @@ -14,9 +14,9 @@ "applicationHasRestrictions": true, "applicationHasGuidance": true, "lpaDonorSignatureDate": "2018-06-30", - "lifeSustainingTreatment": "yes", + "lifeSustainingTreatment": "Option A", "onlineLpaId": "ABC123", - "attorneyActDecisions": "Example decision", + "attorneyActDecisions": "jointly", "donor": { "id": 0, "uId": "700000000053", diff --git a/service-front/app/test/fixtures/full_example.json b/service-front/app/test/fixtures/full_example.json index 0ee7d679c3..1d72f1e121 100644 --- a/service-front/app/test/fixtures/full_example.json +++ b/service-front/app/test/fixtures/full_example.json @@ -16,9 +16,9 @@ "applicationHasRestrictions": true, "applicationHasGuidance": true, "lpaDonorSignatureDate": "2018-06-30", - "lifeSustainingTreatment": "yes", + "lifeSustainingTreatment": "Option A", "onlineLpaId": "ABC123", - "attorneyActDecisions": "Example decision", + "attorneyActDecisions": "jointly", "hasSeveranceWarning": true, "donor": { "id": 0, diff --git a/service-front/app/test/fixtures/full_example_signed_before_2016.json b/service-front/app/test/fixtures/full_example_signed_before_2016.json index c55c371de6..4b22813620 100644 --- a/service-front/app/test/fixtures/full_example_signed_before_2016.json +++ b/service-front/app/test/fixtures/full_example_signed_before_2016.json @@ -16,9 +16,9 @@ "applicationHasRestrictions": true, "applicationHasGuidance": true, "lpaDonorSignatureDate": "2015-06-30", - "lifeSustainingTreatment": "yes", + "lifeSustainingTreatment": "Option A", "onlineLpaId": "ABC123", - "attorneyActDecisions": "Example decision", + "attorneyActDecisions": "jointly", "donor": { "id": 0, "uId": "700000000054", diff --git a/service-front/app/test/fixtures/simple_example.json b/service-front/app/test/fixtures/simple_example.json index 0aaf437fb8..996a0bf278 100644 --- a/service-front/app/test/fixtures/simple_example.json +++ b/service-front/app/test/fixtures/simple_example.json @@ -18,7 +18,7 @@ "lpaDonorSignatureDate": "2018-06-30", "lifeSustainingTreatment": null, "onlineLpaId": "ABC123", - "attorneyActDecisions": "Example decision", + "attorneyActDecisions": "jointly", "donor": { "id": 0, "uId": "7000-0000-0054", From 69c1773741c5b341bc685f599d6aa55a170c7db5 Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Wed, 2 Oct 2024 11:39:21 +0100 Subject: [PATCH 03/14] UML-3619 wip --- .../src/App/src/Entity/Sirius/SiriusLpa.php | 32 ++++++++++++++++++- .../App/src/Service/Lpa/LpaDataFormatter.php | 2 -- .../Lpa/ResolveActor/SiriusHasActorTrait.php | 6 ++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php index 18e14cacee..6d02ab7010 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php @@ -9,13 +9,18 @@ use App\Enum\HowAttorneysMakeDecisions; use App\Enum\LifeSustainingTreatment; use App\Enum\LpaType; +use App\Service\Lpa\IsValid\IsValidInterface; +use App\Service\Lpa\ResolveActor\HasActorInterface; +use App\Service\Lpa\ResolveActor\SiriusHasActorTrait; use DateTimeImmutable; use EventSauce\ObjectHydrator\PropertyCasters\CastListToType; use App\Entity\Sirius\Casters\CastSiriusDonor; use App\Entity\Sirius\Casters\CastToSiriusLifeSustainingTreatment; -class SiriusLpa extends Lpa +class SiriusLpa extends Lpa implements HasActorInterface, IsValidInterface { + use SiriusHasActorTrait; + public function __construct( ?bool $applicationHasGuidance, ?bool $applicationHasRestrictions, @@ -75,4 +80,29 @@ public function __construct( $withdrawnDate ); } + + private function getAttorneys(): array + { + return $this->attorneys ?? []; + } + + private function getDonor(): ?object + { + return $this->donor; + } + + private function getTrustCorporations(): array + { + return $this->trustCorporations ?? []; + } + + public function getStatus(): string + { + return $this->status ?? ''; + } + + public function getUid(): string + { + return $this->uId ?? ''; + } } diff --git a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php index 42f58bf84c..2447d1c03d 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php @@ -10,7 +10,6 @@ use EventSauce\ObjectHydrator\KeyFormatterWithoutConversion; use EventSauce\ObjectHydrator\ObjectMapperUsingReflection; use EventSauce\ObjectHydrator\UnableToHydrateObject; -use EventSauce\ObjectHydrator\UnableToSerializeObject; class LpaDataFormatter { @@ -26,7 +25,6 @@ public function __construct() } /** - * @throws UnableToSerializeObject * @throws UnableToHydrateObject */ public function __invoke(array $lpa) diff --git a/service-api/app/src/App/src/Service/Lpa/ResolveActor/SiriusHasActorTrait.php b/service-api/app/src/App/src/Service/Lpa/ResolveActor/SiriusHasActorTrait.php index 1edb34973f..a56960e4e8 100644 --- a/service-api/app/src/App/src/Service/Lpa/ResolveActor/SiriusHasActorTrait.php +++ b/service-api/app/src/App/src/Service/Lpa/ResolveActor/SiriusHasActorTrait.php @@ -60,9 +60,9 @@ private function isATrustCorporation(string $uid): ?LpaActor return null; } - abstract private function getAttorneys(): array; + abstract private function getAttorneys(): ?array; - abstract private function getDonor(): array; + abstract private function getDonor(): ?object; - abstract private function getTrustCorporations(): array; + abstract private function getTrustCorporations(): ?array; } From 0d63ae0c0eb46f4142ca5364c94114574b97cc64 Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Thu, 3 Oct 2024 09:34:35 +0100 Subject: [PATCH 04/14] UML-3619 Convert incoming LPAs to combined format (repository layer) --- docker-compose.yml | 4 ++-- .../app/src/App/src/Service/Lpa/LpaManagerFactory.php | 6 +++--- service-api/app/test/fixtures/example_lpa.json | 4 ++-- service-front/app/test/fixtures/full_example.json | 4 ++-- .../app/test/fixtures/full_example_signed_before_2016.json | 4 ++-- service-front/app/test/fixtures/simple_example.json | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index afbf84be39..fc333a8555 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -108,7 +108,7 @@ services: ALLOW_MERIS_LPAS: "false" INSTRUCTIONS_AND_PREFERENCES: "true" ALLOW_GOV_ONE_LOGIN: "true" - SUPPORT_DATASTORE_LPAS: "true" + SUPPORT_DATASTORE_LPAS: "false" # Local only API_SERVICE_URL: @@ -195,7 +195,7 @@ services: ALLOW_MERIS_LPAS: "false" INSTRUCTIONS_AND_PREFERENCES: "true" ALLOW_GOV_ONE_LOGIN: "true" - SUPPORT_DATASTORE_LPAS: "true" + SUPPORT_DATASTORE_LPAS: "false" # Local only AWS_ACCESS_KEY_ID: "devkey" diff --git a/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php b/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php index 7f98fd5a78..f080ec8b44 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaManagerFactory.php @@ -16,9 +16,9 @@ public function __construct(private readonly ContainerInterface $container) public function __invoke(): LpaManagerInterface { -// if (($this->container->get(FeatureEnabled::class))('support_datastore_lpas')) { -// throw new RuntimeException('Datastore LPA support is enabled but not implemented yet.'); -// } + if (($this->container->get(FeatureEnabled::class))('support_datastore_lpas')) { + throw new RuntimeException('Datastore LPA support is enabled but not implemented yet.'); + } return $this->container->get(SiriusLpaManager::class); } diff --git a/service-api/app/test/fixtures/example_lpa.json b/service-api/app/test/fixtures/example_lpa.json index c6b10036ed..6b03b5feb6 100644 --- a/service-api/app/test/fixtures/example_lpa.json +++ b/service-api/app/test/fixtures/example_lpa.json @@ -14,9 +14,9 @@ "applicationHasRestrictions": true, "applicationHasGuidance": true, "lpaDonorSignatureDate": "2018-06-30", - "lifeSustainingTreatment": "Option A", + "lifeSustainingTreatment": "yes", "onlineLpaId": "ABC123", - "attorneyActDecisions": "jointly", + "attorneyActDecisions": "Example decision", "donor": { "id": 0, "uId": "700000000053", diff --git a/service-front/app/test/fixtures/full_example.json b/service-front/app/test/fixtures/full_example.json index 1d72f1e121..0ee7d679c3 100644 --- a/service-front/app/test/fixtures/full_example.json +++ b/service-front/app/test/fixtures/full_example.json @@ -16,9 +16,9 @@ "applicationHasRestrictions": true, "applicationHasGuidance": true, "lpaDonorSignatureDate": "2018-06-30", - "lifeSustainingTreatment": "Option A", + "lifeSustainingTreatment": "yes", "onlineLpaId": "ABC123", - "attorneyActDecisions": "jointly", + "attorneyActDecisions": "Example decision", "hasSeveranceWarning": true, "donor": { "id": 0, diff --git a/service-front/app/test/fixtures/full_example_signed_before_2016.json b/service-front/app/test/fixtures/full_example_signed_before_2016.json index 4b22813620..c55c371de6 100644 --- a/service-front/app/test/fixtures/full_example_signed_before_2016.json +++ b/service-front/app/test/fixtures/full_example_signed_before_2016.json @@ -16,9 +16,9 @@ "applicationHasRestrictions": true, "applicationHasGuidance": true, "lpaDonorSignatureDate": "2015-06-30", - "lifeSustainingTreatment": "Option A", + "lifeSustainingTreatment": "yes", "onlineLpaId": "ABC123", - "attorneyActDecisions": "jointly", + "attorneyActDecisions": "Example decision", "donor": { "id": 0, "uId": "700000000054", diff --git a/service-front/app/test/fixtures/simple_example.json b/service-front/app/test/fixtures/simple_example.json index 996a0bf278..0aaf437fb8 100644 --- a/service-front/app/test/fixtures/simple_example.json +++ b/service-front/app/test/fixtures/simple_example.json @@ -18,7 +18,7 @@ "lpaDonorSignatureDate": "2018-06-30", "lifeSustainingTreatment": null, "onlineLpaId": "ABC123", - "attorneyActDecisions": "jointly", + "attorneyActDecisions": "Example decision", "donor": { "id": 0, "uId": "7000-0000-0054", From e81c3478884020f304adb7b6ca076c6c7f962ea6 Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Thu, 3 Oct 2024 11:46:21 +0100 Subject: [PATCH 05/14] UML-3619 updated tests and added donotserialize on func --- .../src/App/src/DataAccess/ApiGateway/SiriusLpas.php | 8 ++++---- .../app/src/App/src/Entity/Sirius/SiriusLpa.php | 4 +++- .../app/src/App/src/Service/Lpa/LpaDataFormatter.php | 12 ++++++++++-- .../CanSerialiseLpaStoreToModerniseFormatTest.php | 11 ++++++++++- .../CanSerialiseSiriusToModerniseFormatTest.php | 12 +++++++++++- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php b/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php index 6ad5e5abf5..474e89ad0d 100644 --- a/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php +++ b/service-api/app/src/App/src/DataAccess/ApiGateway/SiriusLpas.php @@ -128,12 +128,12 @@ public function lookup(array $uids): array // Handle all request response now foreach ($results as $uid => $result) { $statusCode = $result->getStatusCode(); - $response = json_decode( - $result->getBody()->getContents(), - true, - ); switch ($statusCode) { case 200: + $response = json_decode( + $result->getBody()->getContents(), + true, + ); # TODO: We can some more error checking around this. if (($this->featureEnabled)('support_datastore_lpas')) { $results[$uid] = ($this->lpaDataFormatter)($response); diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php index 6d02ab7010..c057c97707 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php @@ -13,6 +13,7 @@ use App\Service\Lpa\ResolveActor\HasActorInterface; use App\Service\Lpa\ResolveActor\SiriusHasActorTrait; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\PropertyCasters\CastListToType; use App\Entity\Sirius\Casters\CastSiriusDonor; use App\Entity\Sirius\Casters\CastToSiriusLifeSustainingTreatment; @@ -96,11 +97,12 @@ private function getTrustCorporations(): array return $this->trustCorporations ?? []; } + #[DoNotSerialize] public function getStatus(): string { return $this->status ?? ''; } - + #[DoNotSerialize] public function getUid(): string { return $this->uId ?? ''; diff --git a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php index 2447d1c03d..844dbeeb41 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php @@ -6,17 +6,20 @@ use App\Entity\LpaStore\LpaStore; use App\Entity\Sirius\SiriusLpa; +use App\Service\Features\FeatureEnabled; use EventSauce\ObjectHydrator\DefinitionProvider; use EventSauce\ObjectHydrator\KeyFormatterWithoutConversion; use EventSauce\ObjectHydrator\ObjectMapperUsingReflection; use EventSauce\ObjectHydrator\UnableToHydrateObject; +use RuntimeException; class LpaDataFormatter { private ObjectMapperUsingReflection $mapper; - public function __construct() - { + public function __construct( + private FeatureEnabled $featureEnabled, + ) { $this->mapper = new ObjectMapperUsingReflection( new DefinitionProvider( keyFormatter: new KeyFormatterWithoutConversion(), @@ -26,11 +29,16 @@ public function __construct() /** * @throws UnableToHydrateObject + * @throws RuntimeException */ public function __invoke(array $lpa) { $lpaObject = $this->hydrateObject($lpa); + if (!($this->featureEnabled)('support_datastore_lpas')) { + return $this->mapper->serializeObject($lpaObject); + } + return $lpaObject; } diff --git a/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php index 31c9500c8e..dcd83b80d4 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php @@ -4,17 +4,26 @@ namespace AppTest\Entity; +use App\Service\Features\FeatureEnabled; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use App\Service\Lpa\LpaDataFormatter; +use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; class CanSerialiseLpaStoreToModerniseFormatTest extends TestCase { + use ProphecyTrait; private LpaDataFormatter $lpaDataFormatter; + private FeatureEnabled|ObjectProphecy $featureEnabled; public function setUp(): void { - $this->lpaDataFormatter = new LpaDataFormatter(); + $this->featureEnabled = $this->prophesize(FeatureEnabled::class); + $this->featureEnabled + ->__invoke('support_datastore_lpas') + ->willReturn(false); + $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); } #[Test] diff --git a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php index 37397c0a43..3b186283c8 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php @@ -4,17 +4,27 @@ namespace AppTest\Entity; +use App\Service\Features\FeatureEnabled; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use App\Service\Lpa\LpaDataFormatter; +use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; class CanSerialiseSiriusToModerniseFormatTest extends TestCase { + use ProphecyTrait; + private LpaDataFormatter $lpaDataFormatter; + private FeatureEnabled|ObjectProphecy $featureEnabled; public function setUp(): void { - $this->lpaDataFormatter = new LpaDataFormatter(); + $this->featureEnabled = $this->prophesize(FeatureEnabled::class); + $this->featureEnabled + ->__invoke('support_datastore_lpas') + ->willReturn(false); + $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); } #[Test] From 141efe2f65d22cf0738e55f69b6c993e5a7f10ec Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Thu, 3 Oct 2024 13:21:41 +0100 Subject: [PATCH 06/14] UML-3619 updated tests --- .../App/src/Entity/Sirius/SiriusLpaDonor.php | 2 +- ...anSerialiseSiriusToModerniseFormatTest.php | 140 +++++++++++++++++- 2 files changed, 136 insertions(+), 6 deletions(-) diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php index ebb2b172d3..7eb11b4c74 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php @@ -44,7 +44,7 @@ public function __construct( ?string $firstnames, #[MapFrom('linked')] #[LinkedDonorCaster] - public readonly ?array $linkedDonors, + public readonly ?array $linked, ?string $name, ?string $otherNames, #[MapFrom('addresses')] diff --git a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php index 3b186283c8..4bea32beb3 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php @@ -5,6 +5,7 @@ namespace AppTest\Entity; use App\Service\Features\FeatureEnabled; +use DateTimeImmutable; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use App\Service\Lpa\LpaDataFormatter; @@ -20,16 +21,16 @@ class CanSerialiseSiriusToModerniseFormatTest extends TestCase public function setUp(): void { - $this->featureEnabled = $this->prophesize(FeatureEnabled::class); - $this->featureEnabled - ->__invoke('support_datastore_lpas') - ->willReturn(false); + $this->featureEnabled = $this->prophesize(FeatureEnabled::class); $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); } - #[Test] public function can_serialise_sirius_lpa_to_modernise_format(): void { + $this->featureEnabled + ->__invoke('support_datastore_lpas') + ->willReturn(false); + $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/test_lpa.json'), true); $expectedLpa = [ @@ -149,4 +150,133 @@ public function can_serialise_sirius_lpa_to_modernise_format(): void $this->assertEquals($expectedJsonLpa, $jsonLpa); } + + #[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); + + $expectedLpa = [ + 'applicationHasGuidance' => false, + 'applicationHasRestrictions' => false, + 'applicationType' => 'Classic', + 'attorneyActDecisions' => null, + 'attorneys' => [ + [ + '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', + ], + [ + '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' => 'hw', + 'channel' => null, + 'dispatchDate' => null, + 'donor' => [ + 'addressLine1' => '81 Front Street', + 'addressLine2' => 'LACEBY', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'dob' => new DateTimeImmutable('1948-11-01'), + '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' => 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' => [ + [ + '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, + ]; + + $newLpa = ($this->lpaDataFormatter)($lpa); + + $this->assertIsObject($newLpa); + + $jsonLpa = json_encode($newLpa); + $expectedJsonLpa = json_encode($expectedLpa); + + $this->assertEquals($expectedJsonLpa, $jsonLpa); + } } From 310dadacbf1dc0c14af048f41abd8d9c239d79fb Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Thu, 3 Oct 2024 16:34:17 +0100 Subject: [PATCH 07/14] UML-3619 updated tests for codecoverage --- .../src/App/src/Entity/Sirius/SiriusLpa.php | 9 +- .../Service/Lpa/CombinedSiriusLpaTest.php | 256 ++++++++++++++++++ 2 files changed, 262 insertions(+), 3 deletions(-) create mode 100644 service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php index c057c97707..713a305b4f 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpa.php @@ -82,17 +82,20 @@ public function __construct( ); } - private function getAttorneys(): array + #[DoNotSerialize] + public function getAttorneys(): array { return $this->attorneys ?? []; } - private function getDonor(): ?object + #[DoNotSerialize] + public function getDonor(): ?object { return $this->donor; } - private function getTrustCorporations(): array + #[DoNotSerialize] + public function getTrustCorporations(): array { return $this->trustCorporations ?? []; } diff --git a/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php b/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php new file mode 100644 index 0000000000..006abd7b99 --- /dev/null +++ b/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php @@ -0,0 +1,256 @@ + '9 high street', + 'addressLine2' => '', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'dob' => null, + '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' => null, + '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 = (object) [ + 'addressLine1' => '81 Front Street', + 'addressLine2' => 'LACEBY', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'dob' => null, + '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 = 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 = [ + [ + '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 it_can_get_donor(): void + { + $donorMock = (object) [ + 'addressLine1' => '81 Front Street', + 'addressLine2' => 'LACEBY', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'dob' => null, + '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', + ], + ], + ]; + + $sut = $this->getExpectedLpa(); + + $result = $sut->getDonor(); + + $this->assertEquals($donorMock, $result); + } + + #[Test] + public function it_can_get_attorney(): void + { + $attorneyMock = [ + [ + 'addressLine1' => '9 high street', + 'addressLine2' => '', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'dob' => null, + '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' => null, + 'email' => 'XXXXX', + 'firstname' => 'Ann', + 'firstnames' => null, + 'name' => null, + 'otherNames' => null, + 'postcode' => '', + 'surname' => 'Summers', + 'systemStatus' => '1', + 'town' => '', + 'type' => 'Primary', + 'uId' => '7000-0000-0849', + ], + ]; + + $sut = $this->getExpectedLpa(); + + $result = $sut->getAttorneys(); + + $this->assertSame($attorneyMock, $result); + } + + #[Test] + public function it_can_get_trust_corporation(): void + { + $trustCorporationMock = [ + [ + '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', + ], + ]; + + $sut = $this->getExpectedLpa(); + + $result = $sut->getTrustCorporations(); + + $this->assertSame($trustCorporationMock, $result); + } + + #[Test] + public function it_typecasts_on_getters(): void + { + $sut = $this->getExpectedLpa(); + + $this->assertSame('700000000047', $sut->getUid()); + $this->assertSame('Registered', $sut->getStatus()); + } +} From 3baa4a1cc8a16562f3d10d48e995468980e3c28c Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Thu, 3 Oct 2024 16:53:06 +0100 Subject: [PATCH 08/14] UML-3619 updated lint --- .../Service/Lpa/CombinedSiriusLpaTest.php | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php b/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php index 006abd7b99..15ba6848cb 100644 --- a/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php +++ b/service-api/app/test/AppTest/Service/Lpa/CombinedSiriusLpaTest.php @@ -16,11 +16,11 @@ class CombinedSiriusLpaTest extends TestCase public function getExpectedLpa(): SiriusLpa { return new SiriusLpa( - $applicationHasGuidance = false, + $applicationHasGuidance = false, $applicationHasRestrictions = false, - $applicationType = 'Classic', - $attorneyActDecisions = null, - $attorneys = [ + $applicationType = 'Classic', + $attorneyActDecisions = null, + $attorneys = [ [ 'addressLine1' => '9 high street', 'addressLine2' => '', @@ -60,10 +60,10 @@ public function getExpectedLpa(): SiriusLpa 'uId' => '7000-0000-0849', ], ], - $caseSubtype = LpaType::fromShortName('personal-welfare'), - $channel = null, - $dispatchDate = null, - $donor = (object) [ + $caseSubtype = LpaType::fromShortName('personal-welfare'), + $channel = null, + $dispatchDate = null, + $donor = (object)[ 'addressLine1' => '81 Front Street', 'addressLine2' => 'LACEBY', 'addressLine3' => '', @@ -88,19 +88,19 @@ public function getExpectedLpa(): SiriusLpa ], ], ], - $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 = [ + $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 = [ [ 'addressLine1' => 'Street 1', 'addressLine2' => 'Street 2', @@ -121,47 +121,11 @@ public function getExpectedLpa(): SiriusLpa 'uId' => '7000-0015-1998', ], ], - $uId = '700000000047', - $withdrawnDate = null + $uId = '700000000047', + $withdrawnDate = null ); } - #[Test] - public function it_can_get_donor(): void - { - $donorMock = (object) [ - 'addressLine1' => '81 Front Street', - 'addressLine2' => 'LACEBY', - 'addressLine3' => '', - 'country' => '', - 'county' => '', - 'dob' => null, - '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', - ], - ], - ]; - - $sut = $this->getExpectedLpa(); - - $result = $sut->getDonor(); - - $this->assertEquals($donorMock, $result); - } - #[Test] public function it_can_get_attorney(): void { @@ -213,6 +177,42 @@ public function it_can_get_attorney(): void $this->assertSame($attorneyMock, $result); } + #[Test] + public function it_can_get_donor(): void + { + $donorMock = (object)[ + 'addressLine1' => '81 Front Street', + 'addressLine2' => 'LACEBY', + 'addressLine3' => '', + 'country' => '', + 'county' => '', + 'dob' => null, + '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', + ], + ], + ]; + + $sut = $this->getExpectedLpa(); + + $result = $sut->getDonor(); + + $this->assertEquals($donorMock, $result); + } + #[Test] public function it_can_get_trust_corporation(): void { From 527cdeb547551f99d4c3e3e0f2af6cf9d172d948 Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Fri, 4 Oct 2024 11:14:21 +0100 Subject: [PATCH 09/14] UML-3619 updated tests and added test case on hydrating sirius & lpa store --- .../App/src/Service/Lpa/LpaDataFormatter.php | 13 +- ...anHydrateLpaStoreToModerniseFormatTest.php | 141 +++++++++++++++ .../CanHydrateSiriusToModerniseFormatTest.php | 164 ++++++++++++++++++ ...SerialiseLpaStoreToModerniseFormatTest.php | 1 + ...anSerialiseSiriusToModerniseFormatTest.php | 131 +------------- 5 files changed, 313 insertions(+), 137 deletions(-) create mode 100644 service-api/app/test/AppTest/Entity/CanHydrateLpaStoreToModerniseFormatTest.php create mode 100644 service-api/app/test/AppTest/Entity/CanHydrateSiriusToModerniseFormatTest.php diff --git a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php index 844dbeeb41..1c9236e582 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php @@ -6,7 +6,6 @@ use App\Entity\LpaStore\LpaStore; use App\Entity\Sirius\SiriusLpa; -use App\Service\Features\FeatureEnabled; use EventSauce\ObjectHydrator\DefinitionProvider; use EventSauce\ObjectHydrator\KeyFormatterWithoutConversion; use EventSauce\ObjectHydrator\ObjectMapperUsingReflection; @@ -18,7 +17,6 @@ class LpaDataFormatter private ObjectMapperUsingReflection $mapper; public function __construct( - private FeatureEnabled $featureEnabled, ) { $this->mapper = new ObjectMapperUsingReflection( new DefinitionProvider( @@ -35,17 +33,13 @@ public function __invoke(array $lpa) { $lpaObject = $this->hydrateObject($lpa); - if (!($this->featureEnabled)('support_datastore_lpas')) { - return $this->mapper->serializeObject($lpaObject); - } - return $lpaObject; } /** * @throws UnableToHydrateObject */ - public function hydrateObject(array $lpa) + public function hydrateObject(array $lpa): object { $className = $this->getHydrationClass($lpa); @@ -55,6 +49,11 @@ public function hydrateObject(array $lpa) ); } + public function serializeObject(object $lpa): mixed + { + return $this->mapper->serializeObject($lpa); + } + private function getHydrationClass(array $lpa): string { return isset($lpa['uid']) && str_starts_with($lpa['uid'], 'M-') diff --git a/service-api/app/test/AppTest/Entity/CanHydrateLpaStoreToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanHydrateLpaStoreToModerniseFormatTest.php new file mode 100644 index 0000000000..c6e0a4859f --- /dev/null +++ b/service-api/app/test/AppTest/Entity/CanHydrateLpaStoreToModerniseFormatTest.php @@ -0,0 +1,141 @@ +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, + $countryName = '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-api/app/test/AppTest/Entity/CanHydrateSiriusToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanHydrateSiriusToModerniseFormatTest.php new file mode 100644 index 0000000000..4617d09561 --- /dev/null +++ b/service-api/app/test/AppTest/Entity/CanHydrateSiriusToModerniseFormatTest.php @@ -0,0 +1,164 @@ +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-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php index d05084d250..28b3f88c11 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php @@ -14,6 +14,7 @@ class CanSerialiseLpaStoreToModerniseFormatTest extends TestCase { use ProphecyTrait; + private LpaDataFormatter $lpaDataFormatter; private FeatureEnabled|ObjectProphecy $featureEnabled; diff --git a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php index f3a3043dd7..51947366ca 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php @@ -99,7 +99,7 @@ public function can_serialise_sirius_lpa_to_modernise_format(): void 'town' => '', 'type' => 'Primary', 'uId' => '700000000799', - 'linkedDonors' => [ + 'linked' => [ [ 'id' => 7, 'uId' => '700000000799', @@ -150,133 +150,4 @@ public function can_serialise_sirius_lpa_to_modernise_format(): void $this->assertEquals($expectedJsonLpa, $jsonLpa); } - - #[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); - - $expectedLpa = [ - 'applicationHasGuidance' => false, - 'applicationHasRestrictions' => false, - 'applicationType' => 'Classic', - 'attorneyActDecisions' => null, - 'attorneys' => [ - [ - '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', - ], - [ - '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' => 'hw', - 'channel' => null, - 'dispatchDate' => null, - 'donor' => [ - 'addressLine1' => '81 Front Street', - 'addressLine2' => 'LACEBY', - 'addressLine3' => '', - 'country' => '', - 'county' => '', - 'dob' => new DateTimeImmutable('1948-11-01'), - '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' => 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' => [ - [ - '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, - ]; - - $newLpa = ($this->lpaDataFormatter)($lpa); - - $this->assertIsObject($newLpa); - - $jsonLpa = json_encode($newLpa); - $expectedJsonLpa = json_encode($expectedLpa); - - $this->assertEquals($expectedJsonLpa, $jsonLpa); - } } From 720d97a36b4a3fe5a64ab48b9d4c6616e38afefd Mon Sep 17 00:00:00 2001 From: Allen Annom Date: Fri, 4 Oct 2024 13:22:17 +0100 Subject: [PATCH 10/14] UML-3619 updated tests and added test case on serialising sirius & lpa store --- service-api/app/src/App/src/Entity/Lpa.php | 5 ++- .../src/App/src/Entity/LpaStore/LpaStore.php | 5 ++- .../src/Entity/LpaStore/LpaStoreAttorney.php | 5 ++- .../App/src/Entity/LpaStore/LpaStoreDonor.php | 5 ++- .../LpaStore/LpaStoreTrustCorporations.php | 5 +++ .../src/Entity/Sirius/SiriusLpaAttorney.php | 5 ++- .../App/src/Entity/Sirius/SiriusLpaDonor.php | 5 ++- .../Sirius/SiriusLpaTrustCorporations.php | 6 ++- .../App/src/Service/Lpa/LpaDataFormatter.php | 4 +- ...SerialiseLpaStoreToModerniseFormatTest.php | 28 ++++++++++--- ...anSerialiseSiriusToModerniseFormatTest.php | 39 +++++++++++++------ 11 files changed, 86 insertions(+), 26 deletions(-) diff --git a/service-api/app/src/App/src/Entity/Lpa.php b/service-api/app/src/App/src/Entity/Lpa.php index b20b4db472..7aba093f87 100644 --- a/service-api/app/src/App/src/Entity/Lpa.php +++ b/service-api/app/src/App/src/Entity/Lpa.php @@ -8,8 +8,10 @@ use App\Enum\LifeSustainingTreatment; use App\Enum\LpaType; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; +use JsonSerializable; -class Lpa implements \JsonSerializable +class Lpa implements JsonSerializable { public function __construct( public readonly ?bool $applicationHasGuidance, @@ -39,6 +41,7 @@ public function __construct( ) { } + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Entity/LpaStore/LpaStore.php b/service-api/app/src/App/src/Entity/LpaStore/LpaStore.php index f250804124..dd313b6b5b 100644 --- a/service-api/app/src/App/src/Entity/LpaStore/LpaStore.php +++ b/service-api/app/src/App/src/Entity/LpaStore/LpaStore.php @@ -13,10 +13,12 @@ use App\Enum\LifeSustainingTreatment; use App\Enum\LpaType; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastListToType; +use JsonSerializable; -class LpaStore extends Lpa implements \JsonSerializable +class LpaStore extends Lpa implements JsonSerializable { public function __construct( ?bool $applicationHasGuidance, @@ -83,6 +85,7 @@ public function __construct( ); } + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreAttorney.php b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreAttorney.php index 352e45ae40..30932f6c68 100644 --- a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreAttorney.php +++ b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreAttorney.php @@ -9,9 +9,11 @@ use App\Entity\Casters\ExtractTownFromLpaStore; use App\Entity\Person; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; +use JsonSerializable; -class LpaStoreAttorney extends Person implements \JsonSerializable +class LpaStoreAttorney extends Person implements JsonSerializable { public function __construct( #[MapFrom('address')] @@ -65,6 +67,7 @@ public function __construct( ); } + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreDonor.php b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreDonor.php index 77f497f58e..68070b9eaa 100644 --- a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreDonor.php +++ b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreDonor.php @@ -9,9 +9,11 @@ use App\Entity\Casters\ExtractTownFromLpaStore; use App\Entity\Person; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; +use JsonSerializable; -class LpaStoreDonor extends Person implements \JsonSerializable +class LpaStoreDonor extends Person implements JsonSerializable { public function __construct( #[MapFrom('address')] @@ -64,6 +66,7 @@ public function __construct( ); } + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php index 6d077092c7..3a85527a4a 100644 --- a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php @@ -63,4 +63,9 @@ public function __construct( $uId, ); } + + public function companyName(): ?string + { + return $this->companyName; + } } diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaAttorney.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaAttorney.php index 2a4e98c322..dd130f34ff 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaAttorney.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaAttorney.php @@ -4,6 +4,7 @@ namespace App\Entity\Sirius; +use EventSauce\ObjectHydrator\DoNotSerialize; use App\Entity\Sirius\Casters\{ ExtractAddressLine1FromSiriusLpa, ExtractAddressLine2FromSiriusLpa, @@ -18,8 +19,9 @@ use EventSauce\ObjectHydrator\MapFrom; use DateTimeImmutable; use EventSauce\ObjectHydrator\PropertyCasters\CastToType; +use JsonSerializable; -class SiriusLpaAttorney extends Person implements \JsonSerializable +class SiriusLpaAttorney extends Person implements JsonSerializable { public function __construct( #[MapFrom('addresses')] @@ -80,6 +82,7 @@ public function __construct( ); } + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php index 478d859b41..31edca4b55 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaDonor.php @@ -5,6 +5,7 @@ namespace App\Entity\Sirius; use App\Entity\Person; +use EventSauce\ObjectHydrator\DoNotSerialize; use App\Entity\Sirius\Casters\{ExtractAddressLine1FromSiriusLpa, ExtractAddressLine2FromSiriusLpa, ExtractAddressLine3FromSiriusLpa, @@ -17,8 +18,9 @@ use DateTimeImmutable; use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastToType; +use JsonSerializable; -class SiriusLpaDonor extends Person implements \JsonSerializable +class SiriusLpaDonor extends Person implements JsonSerializable { public function __construct( #[MapFrom('addresses')] @@ -82,6 +84,7 @@ public function __construct( ); } + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php index bc9d59f95f..48233b55d0 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php @@ -5,6 +5,7 @@ namespace App\Entity\Sirius; use App\Entity\Person; +use EventSauce\ObjectHydrator\DoNotSerialize; use App\Entity\Sirius\Casters\{ ExtractAddressLine1FromSiriusLpa, ExtractAddressLine2FromSiriusLpa, @@ -18,8 +19,9 @@ use EventSauce\ObjectHydrator\MapFrom; use EventSauce\ObjectHydrator\PropertyCasters\CastToType; use DateTimeImmutable; +use JsonSerializable; -class SiriusLpaTrustCorporations extends Person implements \JsonSerializable +class SiriusLpaTrustCorporations extends Person implements JsonSerializable { public function __construct( #[MapFrom('addresses')] @@ -79,6 +81,8 @@ public function __construct( $uId, ); } + + #[DoNotSerialize] public function jsonSerialize(): mixed { $data = get_object_vars($this); diff --git a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php index 1c9236e582..f157bf317e 100644 --- a/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php +++ b/service-api/app/src/App/src/Service/Lpa/LpaDataFormatter.php @@ -16,8 +16,8 @@ class LpaDataFormatter { private ObjectMapperUsingReflection $mapper; - public function __construct( - ) { + public function __construct() + { $this->mapper = new ObjectMapperUsingReflection( new DefinitionProvider( keyFormatter: new KeyFormatterWithoutConversion(), diff --git a/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php index 28b3f88c11..da88644bce 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseLpaStoreToModerniseFormatTest.php @@ -24,15 +24,12 @@ public function setUp(): void $this->featureEnabled ->__invoke('support_datastore_lpas') ->willReturn(false); - $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); + $this->lpaDataFormatter = new LpaDataFormatter(); } - #[Test] - public function can_serialise_datastore_lpa_to_modernise_format(): void + private function getExpectedLpa(): array { - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/4UX3.json'), true); - - $expectedLpa = [ + return [ 'applicationHasGuidance' => null, 'applicationHasRestrictions' => null, 'applicationType' => null, @@ -117,6 +114,13 @@ public function can_serialise_datastore_lpa_to_modernise_format(): void '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); @@ -125,4 +129,16 @@ public function can_serialise_datastore_lpa_to_modernise_format(): void $this->assertEquals($expectedJsonLpa, $jsonLpa); } + + #[Test] + public function can_serialise_datastore_lpa_using_data_formatter(): void + { + $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/4UX3.json'), true); + $expectedLpa = $this->getExpectedLpa(); + + $newLpa = ($this->lpaDataFormatter)($lpa); + $serialisedLpa = $this->lpaDataFormatter->serializeObject($newLpa); + + $this->assertEquals($expectedLpa, $serialisedLpa); + } } diff --git a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php index 51947366ca..f803e16fd6 100644 --- a/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php +++ b/service-api/app/test/AppTest/Entity/CanSerialiseSiriusToModerniseFormatTest.php @@ -22,18 +22,12 @@ class CanSerialiseSiriusToModerniseFormatTest extends TestCase public function setUp(): void { $this->featureEnabled = $this->prophesize(FeatureEnabled::class); - $this->lpaDataFormatter = new LpaDataFormatter($this->featureEnabled->reveal()); + $this->lpaDataFormatter = new LpaDataFormatter(); } - #[Test] - public function can_serialise_sirius_lpa_to_modernise_format(): void - { - $this->featureEnabled - ->__invoke('support_datastore_lpas') - ->willReturn(false); - $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/test_lpa.json'), true); - - $expectedLpa = [ + private function getExpectedLpa(): array + { + return [ 'applicationHasGuidance' => false, 'applicationHasRestrictions' => false, 'applicationType' => 'Classic', @@ -142,12 +136,35 @@ public function can_serialise_sirius_lpa_to_modernise_format(): void 'uId' => '700000000047', 'withdrawnDate' => null, ]; + } + + #[Test] + public function can_serialise_sirius_lpa_to_modernise_format(): void + { + $this->featureEnabled + ->__invoke('support_datastore_lpas') + ->willReturn(false); - $newLpa = ($this->lpaDataFormatter)($lpa); + $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); } + + #[Test] + public function can_serialise_sirius_lpa_using_data_formatter(): void + { + $lpa = json_decode(file_get_contents(__DIR__ . '../../../../test/fixtures/test_lpa.json'), true); + + $expectedLpa = $this->getExpectedLpa(); + $newLpa = ($this->lpaDataFormatter)($lpa); + $serialisedLpa = $this->lpaDataFormatter->serializeObject($newLpa); + + $this->assertEquals($expectedLpa, $serialisedLpa); + } } From a4d1e41e7113e729533370f5b2ea703482749e00 Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Mon, 7 Oct 2024 14:58:27 +0100 Subject: [PATCH 11/14] implement the interface --- .../LpaStore/LpaStoreTrustCorporations.php | 22 ++++++++++++++++++- .../TrustCorporationStatusInterface.php | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php index 3a85527a4a..fe590c70df 100644 --- a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php @@ -8,10 +8,12 @@ use App\Entity\Casters\ExtractCountryFromLpaStore; use App\Entity\Casters\ExtractTownFromLpaStore; use App\Entity\Person; +use App\Service\Lpa\GetTrustCorporationStatus\TrustCorporationStatusInterface; use DateTimeImmutable; +use EventSauce\ObjectHydrator\DoNotSerialize; use EventSauce\ObjectHydrator\MapFrom; -class LpaStoreTrustCorporations extends Person +class LpaStoreTrustCorporations extends Person implements TrustCorporationStatusInterface { public function __construct( #[MapFrom('address')] @@ -68,4 +70,22 @@ public function companyName(): ?string { return $this->companyName; } + + #[DoNotSerialize] + public function getCompanyName(): string + { + return $this->companyName; + } + + #[DoNotSerialize] + public function getSystemStatus(): bool|string + { + return $this->systemStatus; + } + + #[DoNotSerialize] + public function getUid(): string + { + return $this->uId; + } } diff --git a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php index bff8fe728a..f7377a7372 100644 --- a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php +++ b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php @@ -8,7 +8,7 @@ interface TrustCorporationStatusInterface { public function getCompanyName(): string; - public function getSystemStatus(): bool; + public function getSystemStatus(): bool|string; public function getUid(): string; } From 1af0e707ff2d3361daea324bde69f4b85df899a3 Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Tue, 8 Oct 2024 10:46:25 +0100 Subject: [PATCH 12/14] trust corporations, tests --- .../Sirius/SiriusLpaTrustCorporations.php | 18 ++- .../Service/Lpa/GetTrustCorporationStatus.php | 3 +- .../TrustCorporationStatusInterface.php | 2 +- .../Lpa/GetTrustCorporationStatusTest.php | 122 ++++++++++++++++++ 4 files changed, 142 insertions(+), 3 deletions(-) diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php index 48233b55d0..f4549028fc 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php @@ -5,6 +5,7 @@ namespace App\Entity\Sirius; use App\Entity\Person; +use App\Service\Lpa\GetTrustCorporationStatus\TrustCorporationStatusInterface; use EventSauce\ObjectHydrator\DoNotSerialize; use App\Entity\Sirius\Casters\{ ExtractAddressLine1FromSiriusLpa, @@ -21,7 +22,7 @@ use DateTimeImmutable; use JsonSerializable; -class SiriusLpaTrustCorporations extends Person implements JsonSerializable +class SiriusLpaTrustCorporations extends Person implements JsonSerializable , TrustCorporationStatusInterface { public function __construct( #[MapFrom('addresses')] @@ -95,4 +96,19 @@ public function jsonSerialize(): mixed return $data; } + + public function getCompanyName(): string|null + { + return $this->companyName; + } + + public function getSystemStatus(): bool|string + { + return $this->systemStatus; + } + + public function getUid(): string + { + return $this->uId; + } } diff --git a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus.php b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus.php index 66701d358e..5bcd502674 100644 --- a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus.php +++ b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus.php @@ -25,7 +25,8 @@ public function __invoke(TrustCorporationStatusInterface $trustCorporation): int return TrustCorporationStatuses::GHOST_TC->value; } - if (!$trustCorporation->getSystemStatus()) { + $systemStatus = $trustCorporation->getSystemStatus(); + if (!$systemStatus || $systemStatus === 'false') { $this->logger->debug('Looked up attorney {id} but is inactive', ['id' => $trustCorporation->getUid()]); return TrustCorporationStatuses::INACTIVE_TC->value; } diff --git a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php index f7377a7372..9189b6fb8c 100644 --- a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php +++ b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php @@ -6,7 +6,7 @@ interface TrustCorporationStatusInterface { - public function getCompanyName(): string; + public function getCompanyName(): string|null; public function getSystemStatus(): bool|string; diff --git a/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php b/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php index 3fcd6fb202..41570b5237 100644 --- a/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php +++ b/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php @@ -4,6 +4,8 @@ namespace AppTest\Service\Lpa; +use App\Entity\LpaStore\LpaStoreTrustCorporations; +use App\Entity\Sirius\SiriusLpaTrustCorporations; use App\Service\Lpa\GetTrustCorporationStatus; use App\Service\Lpa\SiriusPerson; use PHPUnit\Framework\Attributes\Test; @@ -26,6 +28,7 @@ public function setUp(): void #[Test] public function returns_0_if_trustCorporation_is_active(): void { + $trustCorporation = new SiriusPerson( [ 'uId' => 7, @@ -41,6 +44,36 @@ public function returns_0_if_trustCorporation_is_active(): void $this->assertEquals(0, ($status)($trustCorporation)); } + #[Test] + public function returns_0_if_trustCorporation_is_active_combined_format_lpastore(): void + { + $trustCorporation = new LpaStoreTrustCorporations( + $addressLine1 = '103 Line 1', + $addressLine2 = null, + $addressLine3 = null, + $countryName = 'UK', + $country = 'GB', + $county = null, + $dob = null, + $email = null, + $firstname = null, + $firstnames = null, + $name = 'ABC Ltd', + $otherNames = null, + $postcode = null, + $surname = null, + $systemStatus = 'active', + $town = 'Town', + $type = null, + $uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da', + ); + + $status = new GetTrustCorporationStatus( + $this->loggerProphecy->reveal() + ); + + $this->assertEquals(0, ($status)($trustCorporation)); + } #[Test] public function returns_1_if_trustCorporation_is_a_ghost(): void { @@ -58,6 +91,36 @@ public function returns_1_if_trustCorporation_is_a_ghost(): void $this->assertEquals(1, ($status)($trustCorporation)); } + #[Test] + public function returns_1_if_trustCorporation_is_a_ghost_combined_format_lpastore(): void + { + $trustCorporation = new LpaStoreTrustCorporations( + $addressLine1 = '103 Line 1', + $addressLine2 = null, + $addressLine3 = null, + $countryName = 'UK', + $country = 'GB', + $county = null, + $dob = null, + $email = null, + $firstname = null, + $firstnames = null, + $name = '', + $otherNames = null, + $postcode = null, + $surname = null, + $systemStatus = 'active', + $town = 'Town', + $type = null, + $uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da', + ); + + $status = new GetTrustCorporationStatus( + $this->loggerProphecy->reveal() + ); + + $this->assertEquals(1, ($status)($trustCorporation)); + } #[Test] public function returns_2_if_trustCorporation_is_inactive(): void @@ -74,6 +137,65 @@ public function returns_2_if_trustCorporation_is_inactive(): void $this->loggerProphecy->reveal() ); + $this->assertEquals(2, ($status)($trustCorporation)); + } + #[Test] + public function returns_2_if_trustCorporation_is_inactive_combined_format_lpastore(): void + { + $trustCorporation = new LpaStoreTrustCorporations( + $addressLine1 = '103 Line 1', + $addressLine2 = null, + $addressLine3 = null, + $countryName = 'UK', + $country = 'GB', + $county = null, + $dob = null, + $email = null, + $firstname = null, + $firstnames = null, + $name = '', + $otherNames = null, + $postcode = null, + $surname = null, + $systemStatus = 'false', + $town = 'Town', + $type = null, + $uId = '1d95993a-ffbb-484c-b2fe-f4cca51801da', + ); + + $status = new GetTrustCorporationStatus( + $this->loggerProphecy->reveal() + ); + + $this->assertEquals(2, ($status)($trustCorporation)); + } + #[Test] + public function returns_2_if_trustCorporation_is_inactive_combined_format_sirius(): void + { + $trustCorporation = new SiriusLpaTrustCorporations( + $addressLine1 = 'Street 1', + $addressLine2 = 'Street 2', + $addressLine3 = 'Street 3', + $country = 'GB', + $county = 'County', + $dob = null, + $email = null, + $firstname = 'trust', + $firstnames = null, + $name = null, + $otherNames = null, + $postcode = 'ABC 123', + $surname = 'test', + $systemStatus = 'false', + $town = 'Town', + $type = 'Primary', + $uId = '7000-0015-1998', + ); + + $status = new GetTrustCorporationStatus( + $this->loggerProphecy->reveal() + ); + $this->assertEquals(2, ($status)($trustCorporation)); } } From 15295fa4cb67cd735667c967e2acff9d7eb304ec Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Tue, 8 Oct 2024 11:15:11 +0100 Subject: [PATCH 13/14] fixes --- .../src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php | 3 +++ .../AppTest/Service/Lpa/GetTrustCorporationStatusTest.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php index f4549028fc..b1cedf675f 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php @@ -97,16 +97,19 @@ public function jsonSerialize(): mixed return $data; } + #[DoNotSerialize] public function getCompanyName(): string|null { return $this->companyName; } + #[DoNotSerialize] public function getSystemStatus(): bool|string { return $this->systemStatus; } + #[DoNotSerialize] public function getUid(): string { return $this->uId; diff --git a/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php b/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php index 41570b5237..a78015cd77 100644 --- a/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php +++ b/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php @@ -98,7 +98,7 @@ public function returns_1_if_trustCorporation_is_a_ghost_combined_format_lpastor $addressLine1 = '103 Line 1', $addressLine2 = null, $addressLine3 = null, - $countryName = 'UK', + $companyName = '', $country = 'GB', $county = null, $dob = null, @@ -146,9 +146,9 @@ public function returns_2_if_trustCorporation_is_inactive_combined_format_lpasto $addressLine1 = '103 Line 1', $addressLine2 = null, $addressLine3 = null, - $countryName = 'UK', $country = 'GB', $county = null, + $companyName = 'XYZ Ltd', $dob = null, $email = null, $firstname = null, From 151585509e6b0462b7d85756a93aa1481d46e1c3 Mon Sep 17 00:00:00 2001 From: Nick Davis Date: Tue, 8 Oct 2024 11:42:50 +0100 Subject: [PATCH 14/14] fixes --- .../src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php | 2 +- .../src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php | 4 ++-- .../TrustCorporationStatusInterface.php | 2 +- .../AppTest/Service/Lpa/GetTrustCorporationStatusTest.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php index fe590c70df..76fc4300be 100644 --- a/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/LpaStore/LpaStoreTrustCorporations.php @@ -74,7 +74,7 @@ public function companyName(): ?string #[DoNotSerialize] public function getCompanyName(): string { - return $this->companyName; + return $this->companyName(); } #[DoNotSerialize] diff --git a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php index b1cedf675f..a3f304b12d 100644 --- a/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php +++ b/service-api/app/src/App/src/Entity/Sirius/SiriusLpaTrustCorporations.php @@ -98,9 +98,9 @@ public function jsonSerialize(): mixed } #[DoNotSerialize] - public function getCompanyName(): string|null + public function getCompanyName(): ?string { - return $this->companyName; + return $this->name; } #[DoNotSerialize] diff --git a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php index 9189b6fb8c..b448804043 100644 --- a/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php +++ b/service-api/app/src/App/src/Service/Lpa/GetTrustCorporationStatus/TrustCorporationStatusInterface.php @@ -6,7 +6,7 @@ interface TrustCorporationStatusInterface { - public function getCompanyName(): string|null; + public function getCompanyName(): ?string; public function getSystemStatus(): bool|string; diff --git a/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php b/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php index a78015cd77..4093c274bd 100644 --- a/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php +++ b/service-api/app/test/AppTest/Service/Lpa/GetTrustCorporationStatusTest.php @@ -182,7 +182,7 @@ public function returns_2_if_trustCorporation_is_inactive_combined_format_sirius $email = null, $firstname = 'trust', $firstnames = null, - $name = null, + $name = 'XYZ Ltd', $otherNames = null, $postcode = 'ABC 123', $surname = 'test',