-
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.
fix: vol 5955 transport consultant bug (#507)
* fix: amend form inputs * fix: added check for organisations with no op admin VOL-5955 (#503) * feat: partially complete fetchOperatorDetials Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com> * fix: amend the form for conditional licence field * fix: amended routing * fix: updated to use new query * feat: add a check for existing licence plus whether it has operator admin (#505) * chore: olcs-common 7.16.0 olcs-transfer 7.9.0 (#506) * chore: olcs-common 7.16.0 olcs-transfer 7.9.0 * fix: add sec ignore for xml * fix: move snyk ignore --------- Co-authored-by: Shaun Hare <shaun.hare@dvsa.gov.uk> * feat: added files for ERRU version 3.4 VOL-5800 (#504) * chore: wip needs queryhandler setting * fix: temp push to check * fix: wrong import for query * fix: extra whitespace --------- Signed-off-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com> Co-authored-by: Ian Lindsay <6673081+ilindsay@users.noreply.github.com> Co-authored-by: Gabriel Guimaraes <80750139+gabrielg2020@users.noreply.github.com>
- Loading branch information
1 parent
13f85f8
commit 04461a2
Showing
13 changed files
with
317 additions
and
46 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
39 changes: 39 additions & 0 deletions
39
app/api/module/Api/src/Domain/QueryHandler/Licence/ExistsWithOperatorAdmin.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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\Olcs\Api\Domain\QueryHandler\Licence; | ||
|
||
use Dvsa\Olcs\Api\Domain\Exception\NotFoundException; | ||
use Dvsa\Olcs\Api\Domain\QueryHandler\AbstractQueryHandler; | ||
use Dvsa\Olcs\Transfer\Query\QueryInterface; | ||
use Dvsa\Olcs\Api\Domain\Repository\Licence as LicenceRepo; | ||
use Dvsa\Olcs\Transfer\Query\Licence\ExistsWithOperatorAdmin as ExistsWithOperatorAdminQry; | ||
|
||
class ExistsWithOperatorAdmin extends AbstractQueryHandler | ||
{ | ||
protected $repoServiceName = 'Licence'; | ||
|
||
public function handleQuery(QueryInterface $query) | ||
{ | ||
/** | ||
* @var LicenceRepo $repo | ||
* @var ExistsWithOperatorAdminQry $query | ||
*/ | ||
$repo = $this->getRepo(); | ||
|
||
try { | ||
$licence = $repo->fetchByLicNoWithoutAdditionalData($query->getLicNo()); | ||
$licenceExists = true; | ||
$hasOperatorAdmin = $licence->getOrganisation()->hasOperatorAdmin(); | ||
} catch (NotFoundException) { | ||
$licenceExists = false; | ||
$hasOperatorAdmin = false; | ||
} | ||
|
||
return [ | ||
'licenceExists' => $licenceExists, | ||
'hasOperatorAdmin' => $hasOperatorAdmin, | ||
]; | ||
} | ||
} |
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
73 changes: 73 additions & 0 deletions
73
app/api/test/module/Api/src/Domain/QueryHandler/Licence/ExistsWithOperatorAdminTest.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,73 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dvsa\OlcsTest\Api\Domain\QueryHandler\Licence; | ||
|
||
use Dvsa\Olcs\Api\Domain\Exception\NotFoundException; | ||
use Dvsa\Olcs\Api\Domain\QueryHandler\Licence\ExistsWithOperatorAdmin as QueryHandler; | ||
use Dvsa\Olcs\Api\Domain\Repository\Licence as Repo; | ||
use Dvsa\Olcs\Api\Entity\Licence\Licence as LicenceEntity; | ||
use Dvsa\Olcs\Api\Entity\Organisation\Organisation; | ||
use Dvsa\Olcs\Transfer\Query\Licence\ExistsWithOperatorAdmin as Query; | ||
use Dvsa\OlcsTest\Api\Domain\QueryHandler\QueryHandlerTestCase; | ||
use Mockery as m; | ||
|
||
class ExistsWithOperatorAdminTest extends QueryHandlerTestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
$this->sut = new QueryHandler(); | ||
$this->mockRepo('Licence', Repo::class); | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function testHandleQueryNotFound(): void | ||
{ | ||
$licNo = 'PB2141421'; | ||
$query = Query::create(['licNo' => $licNo]); | ||
|
||
$this->repoMap['Licence']->expects('fetchByLicNoWithoutAdditionalData')->with($licNo)->andThrow(NotFoundException::class); | ||
|
||
$expectedResult = [ | ||
'licenceExists' => false, | ||
'hasOperatorAdmin' => false, | ||
]; | ||
|
||
$this->assertEquals($expectedResult, $this->sut->handleQuery($query)); | ||
} | ||
|
||
/** | ||
* @dataProvider dpHandleQuery | ||
*/ | ||
public function testHandleQuery(bool $isOperatorAdmin): void | ||
{ | ||
$licNo = 'PB2141421'; | ||
$query = Query::create(['licNo' => $licNo]); | ||
|
||
$organisation = m::mock(Organisation::class); | ||
$organisation->expects('hasOperatorAdmin')->andReturn($isOperatorAdmin); | ||
|
||
$licence = m::mock(LicenceEntity::class); | ||
$licence->expects('getOrganisation')->andReturn($organisation); | ||
|
||
|
||
$this->repoMap['Licence']->expects('fetchByLicNoWithoutAdditionalData')->with($licNo)->andReturn($licence); | ||
|
||
$expectedResult = [ | ||
'licenceExists' => true, | ||
'hasOperatorAdmin' => $isOperatorAdmin, | ||
]; | ||
|
||
$this->assertEquals($expectedResult, $this->sut->handleQuery($query)); | ||
} | ||
|
||
public function dpHandleQuery(): array | ||
{ | ||
return [ | ||
[true], | ||
[false], | ||
]; | ||
} | ||
} |
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
Oops, something went wrong.