-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from onfido/test/add-tests
test: add tests for onfido-php library
- Loading branch information
Showing
17 changed files
with
1,000 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace Onfido\Test\Resource; | ||
|
||
use Onfido\Test\OnfidoTestCase as OnfidoTestCase; | ||
|
||
class AddressPickerTest extends OnfidoTestCase | ||
{ | ||
|
||
public function testFindAddress() | ||
{ | ||
|
||
$postCode = 'S2 2DF'; | ||
|
||
$addressesWithPostCode = self::$onfido->findAddresses($postCode)['addresses']; | ||
$this->assertSame($postCode, $addressesWithPostCode[0]['postcode']); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
|
||
namespace Onfido\Test\Resource; | ||
|
||
use Onfido\Test\OnfidoTestCase as OnfidoTestCase; | ||
use Onfido\Model\ReportName as ReportName; | ||
use Onfido\Model\Check as Check; | ||
use Onfido\Model\CheckBuilder as CheckBuilder; | ||
use Onfido\Model\UsDrivingLicenceBuilder as UsDrivingLicenceBuilder; | ||
|
||
class ChecksTest extends OnfidoTestCase | ||
{ | ||
private $applicantId; | ||
private $documentId; | ||
private $check; | ||
/** | ||
* Setup before running each test case | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->applicantId = $this->createApplicant()->getId(); | ||
$this->documentId = $this->uploadDocument($this->applicantId)->getId(); | ||
$this->check = $this->createCheck( | ||
null, | ||
$this->applicantId, | ||
$this->documentId, | ||
[ReportName::DOCUMENT, ReportName::IDENTITY_ENHANCED] | ||
); | ||
} | ||
|
||
public function testCreateCheck(): void | ||
{ | ||
$this->assertSame($this->applicantId, $this->check->getApplicantId()); | ||
$this->assertSame(Check::STATUS_IN_PROGRESS, $this->check->getStatus()); | ||
$this->assertSame(2, sizeOf($this->check->getReportIds())); | ||
} | ||
|
||
public function testCreateConsiderCheck(): void | ||
{ | ||
$checkBuilder = new CheckBuilder([ | ||
'applicant_id' => $this->applicantId, | ||
'document_ids' => [$this->documentId], | ||
'report_names' => [ReportName::DOCUMENT], | ||
'consider' => [ReportName::DOCUMENT] | ||
]); | ||
|
||
$check = $this->createCheck($checkBuilder); | ||
$this->assertSame($this->applicantId, $check->getApplicantId()); | ||
} | ||
|
||
public function testCreateDrivingLicenceCheck(): void | ||
{ | ||
$usDrivingLicenceBuilder = new UsDrivingLicenceBuilder([ | ||
'id_number' => '12345', | ||
'issue_state' => 'GA' | ||
]); | ||
|
||
$checkBuilder = new CheckBuilder([ | ||
'applicant_id' => $this->applicantId, | ||
'document_ids' => [$this->documentId], | ||
'report_names' => [ReportName::DOCUMENT], | ||
'us_driving_licence' => $usDrivingLicenceBuilder | ||
]); | ||
|
||
$check = $this->createCheck($checkBuilder); | ||
|
||
$this->assertSame($this->applicantId, $check->getApplicantId()); | ||
} | ||
|
||
public function testListChecks(): void | ||
{ | ||
$listOfChecks = self::$onfido->listChecks($this->applicantId)["checks"]; | ||
|
||
$this->assertGreaterThan(0, sizeOf($listOfChecks)); | ||
} | ||
|
||
public function testFindCheck(): void | ||
{ | ||
$getCheck = self::$onfido->findCheck($this->check->getId()); | ||
|
||
$this->assertSame($this->check->getId(), $getCheck->getId()); | ||
$this->assertSame($this->applicantId, $getCheck->getApplicantId()); | ||
} | ||
|
||
public function testRestartCheck(): void | ||
{ | ||
self::$onfido->resumeCheck($this->check->getId()); | ||
$this->assertTrue(true); | ||
} | ||
|
||
public function testDownloadCheck(): void | ||
{ | ||
$file = self::$onfido->downloadCheck($this->check->getId()); | ||
|
||
$this->assertGreaterThan(0, $file->getSize()); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
namespace Onfido\Test\Resource; | ||
|
||
use Onfido\Test\OnfidoTestCase as OnfidoTestCase; | ||
use Onfido\Model\DocumentTypes as DocumentTypes; | ||
|
||
use Onfido as Onfido; | ||
|
||
|
||
class DocumentsTest extends OnfidoTestCase | ||
{ | ||
private $applicantId; | ||
private $document; | ||
/** | ||
* Setup before running each test case | ||
*/ | ||
public function setUp(): void | ||
{ | ||
$this->applicantId = $this->createApplicant()->getId(); | ||
$this->document = $this->uploadDocument($this->applicantId); | ||
} | ||
|
||
public function testUploadDocument(): void | ||
{ | ||
$this->assertSame($this->applicantId, $this->document->getApplicantId()); | ||
$this->assertSame(DocumentTypes::PASSPORT, $this->document->getType()); | ||
$this->assertSame($this->applicantId, $this->document->getApplicantId()); | ||
} | ||
|
||
public function testListDocuments(): void | ||
{ | ||
$listOfDocuments = self::$onfido->listDocuments($this->applicantId)['documents']; | ||
$this->assertGreaterThan(0, sizeOf($listOfDocuments)); | ||
} | ||
|
||
public function testFindDocument(): void | ||
{ | ||
$getDocument = self::$onfido->findDocument($this->document->getId()); | ||
$this->assertSame($this->document->getId(), $getDocument->getId()); | ||
} | ||
|
||
public function testDownloadDocument(): void | ||
{ | ||
$file = self::$onfido->downloadDocument($this->document->getId()); | ||
|
||
$this->assertGreaterThan(0, $file->getSize()); | ||
} | ||
|
||
public function testDownloadInexistentDocument(): void | ||
{ | ||
$inexistentDocumentId = '00000000-0000-0000-0000-000000000000'; | ||
|
||
$this->expectException(Onfido\ApiException::class); | ||
self::$onfido->downloadDocument($inexistentDocumentId); | ||
} | ||
} | ||
?> |
Oops, something went wrong.