Skip to content

Commit 6a0f0dc

Browse files
Add file-based tests for business cards, checks, and documents
Introduces new test methods for processing business cards, checks, and documents using file paths instead of base64. Existing base64 test methods are renamed for clarity. This improves test coverage and distinguishes between file and base64 input scenarios.
1 parent 955027b commit 6a0f0dc

3 files changed

Lines changed: 75 additions & 3 deletions

File tree

tests/ClientBusinessCardsTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class ClientBusinessCardsTest extends ClientTestCase
88
{
9-
public function test_process_business_card(): void
9+
public function test_process_business_card_base64(): void
1010
{
1111
if ($this->mock_responses) {
1212
$veryfi_client = $this->getMockBuilder(Client::class)
@@ -30,6 +30,30 @@ public function test_process_business_card(): void
3030
$this->assertNotEmpty($json_response['id']);
3131
}
3232

33+
public function test_process_business_card(): void
34+
{
35+
if ($this->mock_responses) {
36+
$veryfi_client = $this->getMockBuilder(Client::class)
37+
->onlyMethods(['exec_curl'])
38+
->setConstructorArgs([$this->client_id, $this->client_secret, $this->username, $this->api_key])
39+
->getMock();
40+
41+
$file_path = __DIR__ . '/resources/processBusinessCard.json';
42+
$file = fopen($file_path, 'r');
43+
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
44+
$veryfi_client->expects($this->atLeastOnce())
45+
->method('exec_curl')
46+
->willReturn($file_data);
47+
48+
} else {
49+
$veryfi_client = new Client($this->client_id, $this->client_secret, $this->username, $this->api_key);
50+
}
51+
52+
$file = $this->receipt_path;
53+
$json_response = json_decode($veryfi_client->process_business_card($file), true);
54+
$this->assertNotEmpty($json_response['id']);
55+
}
56+
3357
public function test_process_business_card_url(): void
3458
{
3559
if ($this->mock_responses) {

tests/ClientChecksTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class ClientChecksTest extends ClientTestCase
88
{
9-
public function test_process_check(): void
9+
public function test_process_check_base64(): void
1010
{
1111
if ($this->mock_responses) {
1212
$veryfi_client = $this->getMockBuilder(Client::class)
@@ -30,6 +30,30 @@ public function test_process_check(): void
3030
$this->assertNotEmpty($json_response['id']);
3131
}
3232

33+
public function test_process_check(): void
34+
{
35+
if ($this->mock_responses) {
36+
$veryfi_client = $this->getMockBuilder(Client::class)
37+
->onlyMethods(['exec_curl'])
38+
->setConstructorArgs([$this->client_id, $this->client_secret, $this->username, $this->api_key])
39+
->getMock();
40+
41+
$file_path = __DIR__ . '/resources/processCheck.json';
42+
$file = fopen($file_path, 'r');
43+
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
44+
$veryfi_client->expects($this->atLeastOnce())
45+
->method('exec_curl')
46+
->willReturn($file_data);
47+
48+
} else {
49+
$veryfi_client = new Client($this->client_id, $this->client_secret, $this->username, $this->api_key);
50+
}
51+
52+
$file = $this->receipt_path;
53+
$json_response = json_decode($veryfi_client->process_check($file), true);
54+
$this->assertNotEmpty($json_response['id']);
55+
}
56+
3357
public function test_process_check_url(): void
3458
{
3559
if ($this->mock_responses) {

tests/ClientDocumentsTest.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function test_get_document(): void
5454
$this->assertEquals($document_id, $json_response['id']);
5555
}
5656

57-
public function test_process_document(): void
57+
public function test_process_document_base64(): void
5858
{
5959
if ($this->mock_responses) {
6060
$veryfi_client = $this->getMockBuilder(Client::class)
@@ -78,6 +78,30 @@ public function test_process_document(): void
7878
$this->assertEquals(strtolower('walgreens'), strtolower($json_response['vendor']['name']));
7979
}
8080

81+
public function test_process_document(): void
82+
{
83+
if ($this->mock_responses) {
84+
$veryfi_client = $this->getMockBuilder(Client::class)
85+
->onlyMethods(['exec_curl'])
86+
->setConstructorArgs([$this->client_id, $this->client_secret, $this->username, $this->api_key])
87+
->getMock();
88+
89+
$file_path = __DIR__ . '/resources/processDocument.json';
90+
$file = fopen($file_path, 'r');
91+
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
92+
$veryfi_client->expects($this->once())
93+
->method('exec_curl')
94+
->willReturn($file_data);
95+
96+
} else {
97+
$veryfi_client = new Client($this->client_id, $this->client_secret, $this->username, $this->api_key);
98+
}
99+
$categories = array('Job Supplies');
100+
$file = $this->receipt_path;
101+
$json_response = json_decode($veryfi_client->process_document($file, $categories), true);
102+
$this->assertEquals(strtolower('walgreens'), strtolower($json_response['vendor']['name']));
103+
}
104+
81105
public function test_update_document(): void
82106
{
83107
if ($this->mock_responses) {

0 commit comments

Comments
 (0)