-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rodion Liuborets
committed
Jun 9, 2021
1 parent
99d8310
commit e7dced3
Showing
7 changed files
with
176 additions
and
3 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
10 changes: 10 additions & 0 deletions
10
src/DocScan/Request/Check/SandboxThirdPartyIdentityCheck.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yoti\Sandbox\DocScan\Request\Check; | ||
|
||
class SandboxThirdPartyIdentityCheck extends SandboxDocumentCheck | ||
{ | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
src/DocScan/Request/Check/SandboxThirdPartyIdentityCheckBuilder.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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yoti\Sandbox\DocScan\Request\Check; | ||
|
||
class SandboxThirdPartyIdentityCheckBuilder extends SandboxDocumentCheckBuilder | ||
{ | ||
|
||
/** | ||
* @return SandboxThirdPartyIdentityCheck | ||
*/ | ||
public function build(): SandboxCheck | ||
{ | ||
$result = new SandboxCheckResult($this->buildReport()); | ||
return new SandboxThirdPartyIdentityCheck($result, $this->documentFilter); | ||
} | ||
} |
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
105 changes: 105 additions & 0 deletions
105
tests/DocScan/Request/Check/SandboxThirdPartyIdentityCheckBuilderTest.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,105 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yoti\Sandbox\Test\DocScan\Request\Check; | ||
|
||
use PHPUnit\Framework\MockObject\MockObject; | ||
use Yoti\Sandbox\DocScan\Request\Check\Report\SandboxBreakdown; | ||
use Yoti\Sandbox\DocScan\Request\Check\Report\SandboxRecommendation; | ||
use Yoti\Sandbox\DocScan\Request\Check\SandboxThirdPartyIdentityCheck; | ||
use Yoti\Sandbox\DocScan\Request\Check\SandboxThirdPartyIdentityCheckBuilder; | ||
use Yoti\Sandbox\Test\TestCase; | ||
|
||
class SandboxThirdPartyIdentityCheckBuilderTest extends TestCase | ||
{ | ||
/** | ||
* @var MockObject|SandboxRecommendation | ||
*/ | ||
private $recommendationMock; | ||
|
||
/** | ||
* @var MockObject|SandboxBreakdown | ||
*/ | ||
private $breakdownMock; | ||
|
||
/** | ||
* @before | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->recommendationMock = $this->createMock(SandboxRecommendation::class); | ||
$this->breakdownMock = $this->createMock(SandboxBreakdown::class); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldThrowExceptionWhenMissingRecommendation(): void | ||
{ | ||
$this->expectException(\TypeError::class); | ||
$this->expectExceptionMessage(SandboxRecommendation::class); | ||
|
||
(new SandboxThirdPartyIdentityCheckBuilder())->build(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldBuildCorrectly(): void | ||
{ | ||
$result = (new SandboxThirdPartyIdentityCheckBuilder()) | ||
->withRecommendation($this->recommendationMock) | ||
->withBreakdown($this->breakdownMock) | ||
->build(); | ||
|
||
$this->assertInstanceOf(SandboxThirdPartyIdentityCheck::class, $result); | ||
|
||
$this->assertJsonStringEqualsJsonString( | ||
json_encode([ | ||
'result' => [ | ||
'report' => [ | ||
'recommendation' => $this->recommendationMock, | ||
'breakdown' => [ | ||
$this->breakdownMock | ||
], | ||
], | ||
], | ||
]), | ||
json_encode($result) | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function shouldAllowOverwritingOfBreakdowns(): void | ||
{ | ||
$breakdowns = [ | ||
$this->breakdownMock, | ||
$this->breakdownMock, | ||
$this->breakdownMock | ||
]; | ||
|
||
$result = (new SandboxThirdPartyIdentityCheckBuilder()) | ||
->withRecommendation($this->recommendationMock) | ||
->withBreakdowns($breakdowns) | ||
->build(); | ||
|
||
$this->assertJsonStringEqualsJsonString( | ||
json_encode([ | ||
'result' => [ | ||
'report' => [ | ||
'recommendation' => $this->recommendationMock, | ||
'breakdown' => [ | ||
$this->breakdownMock, | ||
$this->breakdownMock, | ||
$this->breakdownMock, | ||
], | ||
], | ||
], | ||
]), | ||
json_encode($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