Skip to content

Commit

Permalink
Code tidy ups after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperaj committed Jan 17, 2025
1 parent d84280a commit a2685c1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 239 deletions.
16 changes: 8 additions & 8 deletions service-api/app/features/context/Integration/LpaContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
use App\Service\Lpa\AddLpa\AddLpa;
use App\Service\Lpa\FindActorInLpa\ActorMatch;
use App\Service\Lpa\GetInstructionsAndPreferencesImages;
use App\Service\Lpa\LpaManagerInterface;
use App\Service\Lpa\RemoveLpa;
use App\Service\Lpa\SiriusLpa;
use App\Service\Lpa\SiriusLpaManager;
use App\Service\Lpa\SiriusPerson;
use App\Service\ViewerCodes\ViewerCodeService;
use Aws\CommandInterface;
Expand Down Expand Up @@ -74,7 +74,7 @@ class LpaContext extends BaseIntegrationContext
private string $codesApiPactProvider;
private string $iapImagesApiPactProvider;
private RemoveLpa $deleteLpa;
private SiriusLpaManager $lpaService;
private LpaManagerInterface $lpaService;

/**
* @Given I have previously requested the addition of a paper LPA to my account
Expand Down Expand Up @@ -602,7 +602,7 @@ public function iRequestToAddAnLPAThatIHaveRequestedAnActivationKeyFor(): void

Assert::assertArrayHasKey('actor', $validatedLpa);
Assert::assertArrayHasKey('lpa', $validatedLpa);
Assert::assertEquals($validatedLpa['lpa']['uId'], $this->lpaUid);
Assert::assertEquals($validatedLpa['lpa']->getUid(), $this->lpaUid);
}

/**
Expand Down Expand Up @@ -1280,8 +1280,8 @@ public function iClickToCheckMyAccessCodes(): void
Assert::assertArrayHasKey('date', $lpaData);
Assert::assertArrayHasKey('actor', $lpaData);
Assert::assertEquals($this->userLpaActorToken, $lpaData['user-lpa-actor-token']);
Assert::assertEquals($this->lpa->uId, $lpaData['lpa']['uId']);
Assert::assertEquals($this->actorLpaId, $lpaData['actor']->actor['uId']);
Assert::assertEquals($this->lpa->uId, $lpaData['lpa']->getUid());
Assert::assertEquals($this->actorLpaId, $lpaData['actor']->actor->getUid());

// Get the share codes

Expand Down Expand Up @@ -2031,7 +2031,7 @@ public function iRequestToAddAnLPAWithValidDetails(): void

Assert::assertArrayHasKey('actor', $validatedLpa);
Assert::assertArrayHasKey('lpa', $validatedLpa);
Assert::assertEquals($validatedLpa['lpa']['uId'], $this->lpaUid);
Assert::assertEquals($validatedLpa['lpa']->getUid(), $this->lpaUid);
}

/**
Expand Down Expand Up @@ -2397,7 +2397,7 @@ public function theLPAIsRemoved(): void
*/
public function theLPAIsSuccessfullyAdded(): void
{
$now = (new DateTime())->format('Y-m-d\TH:i:s.u\Z');
$now = (new DateTime())->format('Y-m-d\TH:i:s.u\Z');
$this->userLpaActorToken = '13579';

// UserLpaActorMap::getUsersLpas
Expand Down Expand Up @@ -2463,7 +2463,7 @@ protected function prepareContext(): void

$this->apiFixtures = $this->container->get(MockHandler::class);
$this->awsFixtures = $this->container->get(AwsMockHandler::class);
$this->lpaService = $this->container->get(SiriusLpaManager::class);
$this->lpaService = $this->container->get(LpaManagerInterface::class);
$this->deleteLpa = $this->container->get(RemoveLpa::class);

$config = $this->container->get('config');
Expand Down
2 changes: 0 additions & 2 deletions service-api/app/src/App/src/Service/Lpa/SiriusLpaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

class SiriusLpaManager implements LpaManagerInterface
{
private const ACTIVE_TC = 0;

public function __construct(
private UserLpaActorMapInterface $userLpaActorMapRepository,
private LpasInterface $lpaRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace AppTest\Entity;

use App\Entity\Casters\CastToAttorneyActDecisions;
use App\Entity\Casters\CastToWhenTheLpaCanBeUsed;
use EventSauce\ObjectHydrator\ObjectMapper;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Test;
Expand All @@ -13,12 +13,12 @@
class CastToWhenTheLpaCanBeUsedTest extends TestCase
{
private ObjectMapper $mockHydrator;
private CastToAttorneyActDecisions $castToWhenTheLpaCanBeUsed;
private CastToWhenTheLpaCanBeUsed $castToWhenTheLpaCanBeUsed;

public function setUp(): void
{
$this->mockHydrator = $this->createMock(ObjectMapper::class);
$this->castToWhenTheLpaCanBeUsed = new CastToAttorneyActDecisions();
$this->castToWhenTheLpaCanBeUsed = new CastToWhenTheLpaCanBeUsed();
}

#[DataProvider('whenTheLpaCanBeUsedProvider')]
Expand Down
2 changes: 1 addition & 1 deletion service-front/app/features/actor-view-lpa.feature
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ Feature: View an LPA that I have added to my account
Given I have added a Combined LPA to my account
And I am on the dashboard page
When I request to view an LPA with a donor who is also known as 'Ezra'
Then I will see Ezra in the also known as field
Then I will see Ezra in the also known as field
1 change: 1 addition & 0 deletions service-front/app/features/bootstrap/behat.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'delete_lpa_feature' => true,
'allow_gov_one_login' => true,
'support_datastore_lpas' => false,
'paper_verification' => false,
],
'notify' => [
'api' => [
Expand Down
231 changes: 7 additions & 224 deletions service-front/app/src/Common/src/Service/Lpa/ParseLpaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

use ArrayObject;
use Common\Service\Features\FeatureEnabled;
use Exception;
use Common\Service\Lpa\Factory\LpaDataFormatter;
use Common\Service\Lpa\Factory\PersonDataFormatter;
use Exception;

/**
* Single action invokeable class that transforms incoming LPA data arrays from the API into ones containing
Expand All @@ -22,6 +23,7 @@ public function __construct(
private LpaFactory $lpaFactory,
private InstAndPrefImagesFactory $imagesFactory,
private LpaDataFormatter $lpaDataFormatter,
private PersonDataFormatter $personDataFormatter,
private FeatureEnabled $featureEnabled,
) {
}
Expand Down Expand Up @@ -49,16 +51,15 @@ 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')) {
// 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);
$data['lpa'] = ($this->lpaDataFormatter)($dataItem);
} else {
$data['lpa'] = $this->lpaFactory->createLpaFromData($dataItem);
}
break;
case 'actor':
if ($data['actor'] !== null) {
if (($this->featureEnabled)('support_datastore_lpas')) {
$data['actor']['details'] = ($this->personDataFormatter)($dataItem['details']);
} else {
$data['actor']['details'] = $this->lpaFactory->createCaseActorFromData($dataItem['details']);
}
break;
Expand All @@ -74,222 +75,4 @@ public function __invoke(array $data): ArrayObject

return new ArrayObject($data, ArrayObject::ARRAY_AS_PROPS);
}

/**
* @codeCoverageIgnore
*/
public static function getMockedCombinedFormat(bool $asLpaStoreLpa): array
{
$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' => '[email protected]',
'salutation' => 'Mr',
'firstname' => 'Rachel',
'middlenames' => 'Emma',
'surname' => 'Sanderson',
'otherNames' => 'Ezra',
'addresses' => [
[
'id' => 7,
'town' => 'Townville',
'county' => 'Countyville',
'postcode' => 'DN37 5SH',
'country' => '',
'type' => 'Primary',
'addressLine1' => '81 Front Street',
'addressLine2' => 'LACEBY',
'addressLine3' => '',
],
],
'companyName' => null,
],
'applicationType' => 'Classic',
'caseSubtype' => 'pfa',
'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' => 'Pretendham',
'county' => 'Countyville',
'postcode' => 'DN37 5SH',
'country' => '',
'type' => 'Primary',
'addressLine1' => '9 High street',
'addressLine2' => 'Pretendville',
'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' => 'Hannerton',
'county' => 'Countyville',
'postcode' => 'HA1 4GH',
'country' => '',
'type' => 'Primary',
'addressLine1' => '47 Armington Way',
'addressLine2' => 'Hansville',
'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,
'name' => 'Trust Us Corporation Ltd.',
],
],
'certificateProviders' => [
[
'id' => 11,
'uId' => '7000-0000-0831',
'dob' => null,
'email' => null,
'salutation' => 'Miss',
'firstname' => 'Danielle',
'middlenames' => null,
'surname' => 'Hart ',
'addresses' => [
[
'id' => 11,
'town' => 'Townville',
'county' => '',
'postcode' => 'SK14 0RH',
'country' => '',
'type' => 'Primary',
'addressLine1' => '50 Fordham Rd',
'addressLine2' => 'HADFIELD',
'addressLine3' => '',
],
],
],
],
'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;
}
}
2 changes: 1 addition & 1 deletion service-front/app/test/fixtures/combined_lpa.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@
"uId": "700000000047",
"withdrawnDate": null,
"whenTheLpaCanBeUsed": "when-has-capacity"
}
}

0 comments on commit a2685c1

Please sign in to comment.