-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDK-2438 added face comparison and added related tests
- Loading branch information
1 parent
5c8627c
commit c444d1f
Showing
5 changed files
with
178 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Yoti\Sandbox\DocScan\Request\Check; | ||
|
||
use Yoti\Sandbox\DocScan\SandboxConstants; | ||
|
||
class SandboxFaceComparisonCheck extends SandboxCheck | ||
{ | ||
/** | ||
* @var SandboxFaceComparisonCheckConfig | ||
*/ | ||
private $config; | ||
|
||
public function __construct(SandboxFaceComparisonCheckConfig $config) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
protected function getType(): string | ||
{ | ||
return SandboxConstants::FACE_COMPARISON; | ||
} | ||
|
||
protected function getConfig(): ?SandboxCheckConfigInterface | ||
{ | ||
return $this->config; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/DocScan/Request/Check/SandboxFaceComparisonCheckBuilder.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,19 @@ | ||
<?php | ||
|
||
namespace Yoti\Sandbox\DocScan\Request\Check; | ||
|
||
use Yoti\Sandbox\DocScan\Request\Traits\Builder\SandboxManualCheckTrait; | ||
use Yoti\Util\Validation; | ||
|
||
class SandboxFaceComparisonCheckBuilder | ||
{ | ||
use SandboxManualCheckTrait; | ||
|
||
public function build(): SandboxFaceComparisonCheck | ||
{ | ||
Validation::notEmptyString($this->manualCheck, 'manualCheck'); | ||
|
||
$config = new SandboxFaceComparisonCheckConfig($this->manualCheck); | ||
return new SandboxFaceComparisonCheck($config); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/DocScan/Request/Check/SandboxFaceComparisonCheckConfig.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,36 @@ | ||
<?php | ||
|
||
namespace Yoti\Sandbox\DocScan\Request\Check; | ||
|
||
use stdClass; | ||
|
||
class SandboxFaceComparisonCheckConfig implements SandboxCheckConfigInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
private $manualCheck; | ||
|
||
public function __construct(string $manualCheck) | ||
{ | ||
$this->manualCheck = $manualCheck; | ||
} | ||
|
||
/** | ||
* @return stdClass | ||
*/ | ||
public function jsonSerialize(): stdClass | ||
{ | ||
return (object) [ | ||
'manual_check' => $this->getManualCheck(), | ||
]; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getManualCheck(): string | ||
{ | ||
return $this->manualCheck; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
tests/DocScan/Request/Check/SandboxFaceComparisonCheckBuilderTest.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,54 @@ | ||
<?php | ||
|
||
namespace Yoti\Sandbox\Test\DocScan\Request\Check; | ||
|
||
use Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheck; | ||
use Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheckBuilder; | ||
use Yoti\Sandbox\Test\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheckBuilder | ||
*/ | ||
class SandboxFaceComparisonCheckBuilderTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* @covers ::withManualCheckAlways | ||
* @covers ::setManualCheck | ||
* @covers ::build | ||
*/ | ||
public function shouldCorrectlyBuildSandboxFaceMatchCheck() | ||
{ | ||
$result = (new SandboxFaceComparisonCheckBuilder()) | ||
->withManualCheckNever() | ||
->build(); | ||
|
||
$this->assertInstanceOf(SandboxFaceComparisonCheck::class, $result); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers \Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheck::jsonSerialize | ||
* @covers ::withManualCheckNever | ||
* @covers ::setManualCheck | ||
* @covers ::build | ||
* @covers \Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheck::__construct | ||
* @covers \Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheck::getConfig | ||
* @covers \Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheck::getType | ||
*/ | ||
public function shouldReturnTheCorrectValuesWhenManualCheckIsNever() | ||
{ | ||
$result = (new SandboxFaceComparisonCheckBuilder()) | ||
->withManualCheckNever() | ||
->build(); | ||
|
||
$expected = [ | ||
'type' => 'FACE_COMPARISON', | ||
'config' => [ | ||
'manual_check' => 'NEVER', | ||
], | ||
]; | ||
|
||
$this->assertJsonStringEqualsJsonString(json_encode($expected), json_encode($result)); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
tests/DocScan/Request/Check/SandboxFaceComparisonCheckConfigTest.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,41 @@ | ||
<?php | ||
|
||
namespace Yoti\Sandbox\Test\DocScan\Request\Check; | ||
|
||
use Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheckConfig; | ||
use Yoti\Sandbox\Test\TestCase; | ||
|
||
/** | ||
* @coversDefaultClass \Yoti\Sandbox\DocScan\Request\Check\SandboxFaceComparisonCheckConfig | ||
*/ | ||
class SandboxFaceComparisonCheckConfigTest extends TestCase | ||
{ | ||
private const SOME_MANUAL_CHECK = 'someManualCheck'; | ||
|
||
/** | ||
* @test | ||
* @covers ::__construct | ||
* @covers ::getManualCheck | ||
*/ | ||
public function shouldHoldValuesCorrectly() | ||
{ | ||
$result = new SandboxFaceComparisonCheckConfig(self::SOME_MANUAL_CHECK); | ||
|
||
$this->assertEquals(self::SOME_MANUAL_CHECK, $result->getManualCheck()); | ||
} | ||
|
||
/** | ||
* @test | ||
* @covers ::jsonSerialize | ||
*/ | ||
public function shouldSerializeToJsonCorrectly() | ||
{ | ||
$result = new SandboxFaceComparisonCheckConfig(self::SOME_MANUAL_CHECK); | ||
|
||
$expected = [ | ||
'manual_check' => self::SOME_MANUAL_CHECK, | ||
]; | ||
|
||
$this->assertJsonStringEqualsJsonString(json_encode($expected), json_encode($result)); | ||
} | ||
} |