-
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: added check for organisations with no op admin VOL-5955 (#503)
- Loading branch information
Showing
4 changed files
with
66 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,10 @@ | ||
<?php | ||
|
||
/** | ||
* Organisation | ||
* | ||
* @author Rob Caiger <[email protected]> | ||
*/ | ||
|
||
namespace Dvsa\Olcs\Api\Domain\QueryHandler\Organisation; | ||
|
||
use Dvsa\Olcs\Api\Domain\QueryHandler\AbstractQueryHandler; | ||
use Dvsa\Olcs\Transfer\Query\QueryInterface; | ||
|
||
/** | ||
* Organisation | ||
* | ||
* @author Rob Caiger <[email protected]> | ||
*/ | ||
class Organisation extends AbstractQueryHandler | ||
{ | ||
protected $repoServiceName = 'Organisation'; | ||
|
@@ -37,6 +26,7 @@ public function handleQuery(QueryInterface $query) | |
'isDisqualified' => $organisation->getDisqualifications()->count() > 0, | ||
'taValueOptions' => $this->getTrafficAreaValueOptions($allowedOperatorLocation), | ||
'allowedOperatorLocation' => $allowedOperatorLocation, | ||
'hasOperatorAdmin' => $organisation->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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
<?php | ||
|
||
/** | ||
* Organisation Test | ||
* | ||
* @author Rob Caiger <[email protected]> | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Dvsa\OlcsTest\Api\Domain\QueryHandler\Organisation; | ||
|
||
|
@@ -14,13 +10,7 @@ | |
use Dvsa\Olcs\Api\Domain\Repository\TrafficArea as TrafficAreaRepo; | ||
use Dvsa\Olcs\Transfer\Query\Organisation\Organisation as Qry; | ||
use Mockery as m; | ||
use SAML2\Utilities\ArrayCollection; | ||
|
||
/** | ||
* Organisation Test | ||
* | ||
* @author Rob Caiger <[email protected]> | ||
*/ | ||
class OrganisationTest extends QueryHandlerTestCase | ||
{ | ||
public function setUp(): void | ||
|
@@ -32,14 +22,15 @@ public function setUp(): void | |
parent::setUp(); | ||
} | ||
|
||
public function testHandleQueryDisqualified() | ||
public function testHandleQueryDisqualified(): void | ||
{ | ||
$query = Qry::create(['id' => 111]); | ||
|
||
$mockOrganisation = m::mock(\Dvsa\Olcs\Api\Entity\Organisation\Organisation::class)->makePartial(); | ||
$mockOrganisation->shouldReceive('serialize')->andReturn(['foo' => 'bar']); | ||
$mockOrganisation->shouldReceive('getDisqualifications->count')->andReturn(2); | ||
$mockOrganisation->shouldReceive('getAllowedOperatorLocation')->andReturn('GB')->once(); | ||
$mockOrganisation->expects('hasOperatorAdmin')->withNoArgs()->andReturnTrue(); | ||
|
||
$mockTa = m::mock() | ||
->shouldReceive('getId') | ||
|
@@ -64,20 +55,22 @@ public function testHandleQueryDisqualified() | |
'foo' => 'bar', | ||
'isDisqualified' => true, | ||
'allowedOperatorLocation' => 'GB', | ||
'hasOperatorAdmin' => true, | ||
'taValueOptions' => [1 => 'foo'], | ||
]; | ||
|
||
$this->assertEquals($expected, $this->sut->handleQuery($query)->serialize()); | ||
} | ||
|
||
public function testHandleQueryNotDisqualified() | ||
public function testHandleQueryNotDisqualified(): void | ||
{ | ||
$query = Qry::create(['id' => 111]); | ||
|
||
$mockOrganisation = m::mock(\Dvsa\Olcs\Api\Entity\Organisation\Organisation::class)->makePartial(); | ||
$mockOrganisation->shouldReceive('serialize')->andReturn(['foo' => 'bar']); | ||
$mockOrganisation->shouldReceive('getDisqualifications->count')->andReturn(0); | ||
$mockOrganisation->shouldReceive('getAllowedOperatorLocation')->andReturn('GB')->once(); | ||
$mockOrganisation->expects('hasOperatorAdmin')->withNoArgs()->andReturnFalse(); | ||
|
||
$mockTa = m::mock() | ||
->shouldReceive('getId') | ||
|
@@ -102,6 +95,7 @@ public function testHandleQueryNotDisqualified() | |
'foo' => 'bar', | ||
'isDisqualified' => false, | ||
'allowedOperatorLocation' => 'GB', | ||
'hasOperatorAdmin' => false, | ||
'taValueOptions' => [1 => 'foo'], | ||
]; | ||
|
||
|
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