-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: VOL-5239 create transport consultant reg journey
feat: add signup journey catering for consultants
- Loading branch information
Showing
26 changed files
with
973 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
app/api/module/Api/src/Domain/CommandHandler/User/RegisterConsultantAndOperator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* Register Operator and Consultant | ||
*/ | ||
|
||
namespace Dvsa\Olcs\Api\Domain\CommandHandler\User; | ||
|
||
use Dvsa\Olcs\Api\Domain\CommandHandler\AbstractUserCommandHandler; | ||
use Dvsa\Olcs\Api\Domain\CommandHandler\TransactionedInterface; | ||
use Dvsa\Olcs\Transfer\Command\CommandInterface; | ||
use Dvsa\Olcs\Transfer\Command\User\RegisterUserSelfserve as RegisterUserSelfServeCommand; | ||
|
||
final class RegisterConsultantAndOperator extends AbstractUserCommandHandler implements TransactionedInterface | ||
{ | ||
protected $repoServiceName = 'User'; | ||
|
||
public function handleCommand(CommandInterface $command) | ||
{ | ||
// Register the operator first, a new Org will be created. | ||
$this->result->merge($this->handleSideEffect(RegisterUserSelfServeCommand::create($command->getOperatorDetails()))); | ||
|
||
// Get the newly created user entity | ||
$user = $this->getRepo()->fetchById($this->result->getId('user')); | ||
|
||
// Add the org ID of the newly created user/org to the consultant details, then register the consultant | ||
$consultantDetails = $command->getConsultantDetails(); | ||
$consultantDetails['organisation'] = $user->getOrganisationUsers()->first()->getOrganisation()->getId(); | ||
|
||
$this->result->merge($this->handleSideEffect(RegisterUserSelfServeCommand::create($consultantDetails))); | ||
|
||
return $this->result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/api/module/Email/view/email/en_GB/html/user-registered-tc.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<p>Hello,</p> | ||
|
||
<p>You've been added to the Vehicle Operator Licensing service for <?php echo $this->escapeHtml($this->orgName); ?>.</p> | ||
|
||
<p>Your username is: <?php echo $this->escapeHtml($this->loginId); ?></p> | ||
|
||
<p>You'll receive a second email with a temporary password in the next two hours. If it doesn't arrive email notification@vehicle-operator-licensing.service.gov.uk</p> | ||
|
||
<p> | ||
<a href="<?php echo $this->escapeHtml($this->url); ?>">Sign in</a> | ||
</p> |
9 changes: 9 additions & 0 deletions
9
app/api/module/Email/view/email/en_GB/plain/user-registered-tc.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Hello, | ||
|
||
You've been added to the Vehicle Operator Licensing service for <?php echo $this->orgName; ?>. | ||
|
||
Your username is: <?php echo $this->loginId; ?></p> | ||
|
||
You'll receive a second email with a temporary password in the next two hours. If it doesn't arrive email notification@vehicle-operator-licensing.service.gov.uk | ||
|
||
Sign in at <?php echo $this->url; ?> |
72 changes: 72 additions & 0 deletions
72
app/api/test/module/Api/src/Domain/CommandHandler/User/RegisterConsultantAndOperatorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace Dvsa\OlcsTest\Api\Domain\CommandHandler\User; | ||
|
||
use Dvsa\Olcs\Api\Domain\CommandHandler\User\RegisterConsultantAndOperator; | ||
use Dvsa\Olcs\Api\Domain\Repository\User as UserRepo; | ||
use Dvsa\Olcs\Api\Entity\User\User as UserEntity; | ||
use Dvsa\Olcs\Transfer\Command\User\RegisterConsultantAndOperator as RegisterConsultantAndOperatorCommand; | ||
use Dvsa\Olcs\Transfer\Command\User\RegisterUserSelfserve as RegisterUserSelfServeCommand; | ||
use Dvsa\OlcsTest\Api\Domain\CommandHandler\AbstractCommandHandlerTestCase; | ||
use Dvsa\Olcs\Api\Domain\Command\Result; | ||
use Mockery as m; | ||
|
||
class RegisterConsultantAndOperatorTest extends AbstractCommandHandlerTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
$this->sut = new RegisterConsultantAndOperator(); | ||
$this->mockRepo('User', UserRepo::class); | ||
|
||
$mockAuthService = m::mock(\LmcRbacMvc\Service\AuthorizationService::class); | ||
$this->mockedSmServices['LmcRbacMvc\Service\AuthorizationService'] = $mockAuthService; | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testHandleCommand() | ||
{ | ||
$operatorDetails = ['organisationName' => 'Operator Org',]; | ||
|
||
$command = RegisterConsultantAndOperatorCommand::create( | ||
[ | ||
'operatorDetails' => $operatorDetails, | ||
'consultantDetails' => [] | ||
]); | ||
|
||
$operatorResult = new Result(); | ||
$operatorResult->addId('user', 100)->addMessage('User created successfully'); | ||
|
||
$this->expectedSideEffect( | ||
RegisterUserSelfServeCommand::class, | ||
$operatorDetails, | ||
$operatorResult | ||
); | ||
|
||
$organisationId = 200; | ||
$organisation = m::mock(); | ||
$organisation->shouldReceive('getId')->andReturn($organisationId); | ||
|
||
$organisationUser = m::mock(); | ||
$organisationUser->shouldReceive('getOrganisation')->andReturn($organisation); | ||
|
||
$user = m::mock(UserEntity::class)->makePartial(); | ||
$user->shouldReceive('getOrganisationUsers->first')->andReturn($organisationUser); | ||
|
||
$this->repoMap['User']->shouldReceive('fetchById')->with(100)->andReturn($user); | ||
|
||
$consultantDetails['organisation'] = $organisationId; | ||
|
||
$consultantResult = new Result(); | ||
$consultantResult->addId('user', 101)->addMessage('User created successfully'); | ||
|
||
$this->expectedSideEffect( | ||
RegisterUserSelfServeCommand::class, | ||
$consultantDetails, | ||
$consultantResult | ||
); | ||
|
||
$result = $this->sut->handleCommand($command); | ||
$this->assertEquals(['User created successfully', 'User created successfully'], $result->getMessages()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.