diff --git a/api/app/src/FixtureFactory/PreRegistrationFactory.php b/api/app/src/FixtureFactory/PreRegistrationFactory.php index 3c26f0bf70..2a0f6b5145 100644 --- a/api/app/src/FixtureFactory/PreRegistrationFactory.php +++ b/api/app/src/FixtureFactory/PreRegistrationFactory.php @@ -20,13 +20,14 @@ public function __construct(private PreRegistrationDTOFactory $preRegistrationFa public function create(array $data): PreRegistration { $caseNumber = str_pad((string) rand(1, 99999999), 8, '0', STR_PAD_LEFT); - $deputyNumber = str_pad((string) rand(1, 999999999999), 12, '0', STR_PAD_LEFT); + $generateDeputyUidIfNotSet = '7'.str_pad((string) rand(1, 99999999), 11, '0', STR_PAD_LEFT); + $deputyUid = array_key_exists('deputyUid', $data) && strval($data['deputyUid']) ? strval($data['deputyUid']) : $generateDeputyUidIfNotSet; $reportType = 'ndr' == $data['reportType'] ? 'OPG102' : $data['reportType']; $dto = (new LayDeputyshipDto()) ->setCaseNumber($data['caseNumber'] ?? $caseNumber) ->setClientSurname($data['clientLastName'] ?? 'Smith') - ->setDeputyUid($deputyNumber) + ->setDeputyUid($deputyUid) ->setDeputyAddress1($data['deputyAddress1'] ?? 'Victoria Park') ->setDeputyAddress2($data['deputyAddress2'] ?? 'Fakeville') ->setDeputyAddress3($data['deputyAddress3'] ?? 'Pretendham') diff --git a/api/app/src/FixtureFactory/UserFactory.php b/api/app/src/FixtureFactory/UserFactory.php index ac5394a223..17ac319f5a 100644 --- a/api/app/src/FixtureFactory/UserFactory.php +++ b/api/app/src/FixtureFactory/UserFactory.php @@ -40,7 +40,8 @@ public function create(array $data): User ->setAddressPostcode(isset($data['postCode']) ? $data['postCode'] : 'SW1') ->setAddressCountry('GB') ->setRoleName($roleName) - ->setAgreeTermsUse(true); + ->setAgreeTermsUse(true) + ->setDeputyUid(User::TYPE_LAY === $data['deputyType'] ? $data['deputyUid'] : null); if ('true' === $data['activated'] || true === $data['activated']) { $user->setPassword($this->passwordHasher->hashPassword($user, 'DigidepsPass1234')); @@ -135,10 +136,12 @@ public function createCoDeputy(User $originalDeputy, Client $client, array $data ->setActive($data['activated']) ->setRegistrationDate(new \DateTime()) ->setCoDeputyClientConfirmed(true) - ->setActive(true); + ->setActive(true) + ->setDeputyUid('7'.str_pad((string) rand(1, 99999999), 11, '0', STR_PAD_LEFT)); if ('true' === $data['activated'] || true === $data['activated']) { - $user2->setPassword($this->passwordHasher->hashPassword($user2, 'DigidepsPass1234')); + $user2->setPassword($this->passwordHasher->hashPassword($user2, 'DigidepsPass1234')) + ->setIsPrimary(true); } else { $user2->setActive(false); } diff --git a/api/app/src/v2/Fixture/Controller/FixtureController.php b/api/app/src/v2/Fixture/Controller/FixtureController.php index a0c1e0e0b9..485b9f91ef 100644 --- a/api/app/src/v2/Fixture/Controller/FixtureController.php +++ b/api/app/src/v2/Fixture/Controller/FixtureController.php @@ -83,6 +83,7 @@ public function createCourtOrderAction(Request $request) 'deputyLastName' => $deputy->getLastname(), 'deputyFirstName' => $deputy->getFirstName(), 'reportType' => $fromRequest['reportType'], + 'deputyUid' => $fromRequest['deputyUid'], ] ); @@ -97,6 +98,7 @@ public function createCourtOrderAction(Request $request) } if (User::TYPE_LAY === $fromRequest['deputyType']) { + $deputy->setIsPrimary(true); $deputy->addClient($client); } else { $this->createOrgAndAttachParticipants($fromRequest, $deputy, $client); @@ -114,6 +116,7 @@ public function createCourtOrderAction(Request $request) 'deputyLastName' => $coDeputy->getLastname(), 'deputyFirstName' => $coDeputy->getFirstName(), 'reportType' => $fromRequest['reportType'], + 'deputyUid' => $coDeputy->getDeputyUid(), ] ); @@ -154,6 +157,7 @@ private function createDeputy($fromRequest): User 'email' => $fromRequest['deputyEmail'], 'activated' => $fromRequest['activated'], 'coDeputyEnabled' => $fromRequest['coDeputyEnabled'], + 'deputyUid' => $fromRequest['deputyUid'], ]); $this->em->persist($deputy); @@ -252,7 +256,7 @@ private function buildDeputy(User $deputy, array $fromRequest) ->setFirstname($deputy->getFirstname()) ->setLastname($deputy->getLastname()) ->setEmail1($deputy->getEmail()) - ->setDeputyUid($fromRequest['caseNumber'].mt_rand(1, 100)) + ->setDeputyUid('70'.str_pad($fromRequest['caseNumber'].mt_rand(1, 100), 10)) ->setAddress1($deputy->getAddress1()) ->setAddressPostcode($deputy->getAddressPostcode()) ->setPhoneMain($deputy->getPhoneMain()); diff --git a/api/app/tests/Unit/Controller/SelfRegisterControllerTest.php b/api/app/tests/Unit/Controller/SelfRegisterControllerTest.php index d32cdacf12..dacd716cd4 100644 --- a/api/app/tests/Unit/Controller/SelfRegisterControllerTest.php +++ b/api/app/tests/Unit/Controller/SelfRegisterControllerTest.php @@ -737,7 +737,7 @@ private function generateDeputyPrimaryAccount() 'data' => [ 'firstname' => 'Sue', 'lastname' => 'Jones', - 'email' => sprintf('firstdeputyaccount%s@example.com', rand(1, 20)), + 'email' => sprintf('firstdeputy%s@example.com', $casenumber), 'postcode' => 'SW1', 'client_firstname' => 'John', 'client_lastname' => 'Smith', diff --git a/client/app/src/Controller/Admin/FixtureController.php b/client/app/src/Controller/Admin/FixtureController.php index e6e046b1a7..ee975effff 100644 --- a/client/app/src/Controller/Admin/FixtureController.php +++ b/client/app/src/Controller/Admin/FixtureController.php @@ -93,6 +93,7 @@ public function courtOrdersAction(Request $request) $courtDate = $request->get('court-date') ? new \DateTime($request->get('court-date')) : new \DateTime(); $deputyEmail = $request->query->get('deputy-email', sprintf('original-%s-deputy-%s@fixture.com', strtolower($submitted['deputyType']), mt_rand(1000, 9999))); $caseNumber = $request->get('case-number', ClientHelpers::createValidCaseNumber()); + $deputyUid = intval('7'.str_pad((string) mt_rand(1, 99999999), 11, '0', STR_PAD_LEFT)); $response = $this->restClient->post('v2/fixture/court-order', json_encode([ 'deputyType' => $submitted['deputyType'], @@ -105,6 +106,7 @@ public function courtOrdersAction(Request $request) 'activated' => $submitted['activated'], 'orgSizeClients' => $submitted['orgSizeClients'], 'orgSizeUsers' => $submitted['orgSizeUsers'], + 'deputyUid' => $deputyUid, ])); $query = ['query' => ['filter_by_ids' => implode(',', $response['deputyIds'])]]; diff --git a/client/app/src/Service/Client/Internal/ClientApi.php b/client/app/src/Service/Client/Internal/ClientApi.php index 709a438a36..7704c39283 100644 --- a/client/app/src/Service/Client/Internal/ClientApi.php +++ b/client/app/src/Service/Client/Internal/ClientApi.php @@ -172,7 +172,7 @@ public function getWithUsersV2(int $clientId, array $includes = []) public function getById(int $clientId, array $includes = []) { return $this->restClient->get( - sprintf(self::GET_CLIENT_BY_ID_V2, $clientId), + sprintf(self::GET_CLIENT_BY_ID, $clientId), 'Client', [ 'client',