|
1
|
|
|
<?php |
|
2
|
|
|
namespace Tests\Unit; |
|
3
|
|
|
|
|
4
|
|
|
use GuzzleHttp\Psr7\Response; |
|
5
|
|
|
use Lyal\Checkr\Entities\Resources\Document; |
|
6
|
|
|
use Tests\UnitTestCase; |
|
7
|
|
|
|
|
8
|
|
|
class DocumentTest extends UnitTestCase |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
private $jsonString = '{ |
|
12
|
|
|
"id": "4722c07dd9a10c3985ae432a", |
|
13
|
|
|
"object": "document", |
|
14
|
|
|
"created_at": "2015-02-11T20:01:50Z", |
|
15
|
|
|
"download_uri": "https://checkr-documents.checkr.com/download_path", |
|
16
|
|
|
"filesize": 8576, |
|
17
|
|
|
"filename": "1423684910_candidate_driver_license.jpg", |
|
18
|
|
|
"type": "driver_license", |
|
19
|
|
|
"content_type": "image/jpeg" |
|
20
|
|
|
}'; |
|
21
|
|
|
|
|
22
|
|
|
public function testInstantiation() |
|
23
|
|
|
{ |
|
24
|
|
|
$this->assertInstanceOf('Lyal\Checkr\Entities\Resources\Document', $this->getDocument()); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function testSetId() |
|
28
|
|
|
{ |
|
29
|
|
|
$document = $this->getDocument(); |
|
30
|
|
|
$document->id = 'e44aa283528e6fde7d542194'; |
|
31
|
|
|
$this->assertSame('e44aa283528e6fde7d542194', $document->id); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
public function testFields() |
|
35
|
|
|
{ |
|
36
|
|
|
$values = [ |
|
37
|
|
|
'id' => '4722c07dd9a10c3985ae432a', |
|
38
|
|
|
'object' => 'document', |
|
39
|
|
|
'created_at' => '2015-02-11T20:01:50Z', |
|
40
|
|
|
'download_uri' => 'https://checkr-documents.checkr.com/download_path', |
|
41
|
|
|
'filesize' => '8576', |
|
42
|
|
|
'filename' => '1423684910_candidate_driver_license.jpg', |
|
43
|
|
|
'type' => 'driver_license', |
|
44
|
|
|
'content_type' => 'image/jpeg', |
|
45
|
|
|
]; |
|
46
|
|
|
|
|
47
|
|
|
$document = $this->getDocument($values); |
|
48
|
|
|
|
|
49
|
|
|
foreach ($values as $key => $value) { |
|
50
|
|
|
$this->assertEquals($value, $document->{$key}); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public function testUpload() |
|
56
|
|
|
{ |
|
57
|
|
|
$responses = [new Response(200, [], $this->jsonString)]; |
|
58
|
|
|
$document = $this->getDocument(NULL, $responses); |
|
59
|
|
|
$response = $document->upload('drivers_license', __DIR__ . '/DocumentTest.php', '3333c07dd9a10c3985ae432a'); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertEquals('4722c07dd9a10c3985ae432a', $response->id); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
protected function getDocument($values = NULL, $responses = []) |
|
65
|
|
|
{ |
|
66
|
|
|
return new Document($values,$this->getClient($responses)); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|