Skip to content

Commit 31c5f2f

Browse files
Update ClientTest.php
1 parent 17f4e8b commit 31c5f2f

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

tests/ClientTest.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,4 +459,50 @@ public function test_delete_tag(): void
459459
$json_response = json_decode($veryfi_client->delete_tag($document_id, $tag_id), true);
460460
$this->assertEmpty($json_response);
461461
}
462+
463+
public function test_replace_document_tags(): void
464+
{
465+
$document_id = 140804210;
466+
if ($this->mock_responses) {
467+
$veryfi_client = $this->getMockBuilder(Client::class)
468+
->onlyMethods(['exec_curl'])
469+
->setConstructorArgs([$this->client_id, $this->client_secret, $this->username, $this->api_key])
470+
->getMock();
471+
472+
$file_path = __DIR__ . '/resources/getTags.json';
473+
$file = fopen($file_path, 'r');
474+
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
475+
$veryfi_client->expects($this->once())
476+
->method('exec_curl')
477+
->willReturn($file_data);
478+
} else {
479+
$veryfi_client = new Client($this->client_id, $this->client_secret, $this->username, $this->api_key);
480+
}
481+
$tags = array('TAG_1', 'TAG_2', 'TAG_3');
482+
$json_response = json_decode($veryfi_client->replace_tags($document_id, $tags), true);
483+
$this->assertNotEmpty($json_response);
484+
}
485+
486+
public function test_add_document_tags(): void
487+
{
488+
$document_id = 140804210;
489+
if ($this->mock_responses) {
490+
$veryfi_client = $this->getMockBuilder(Client::class)
491+
->onlyMethods(['exec_curl'])
492+
->setConstructorArgs([$this->client_id, $this->client_secret, $this->username, $this->api_key])
493+
->getMock();
494+
495+
$file_path = __DIR__ . '/resources/getTags.json';
496+
$file = fopen($file_path, 'r');
497+
$file_data = mb_convert_encoding(fread($file, filesize($file_path)), 'UTF-8');
498+
$veryfi_client->expects($this->once())
499+
->method('exec_curl')
500+
->willReturn($file_data);
501+
} else {
502+
$veryfi_client = new Client($this->client_id, $this->client_secret, $this->username, $this->api_key);
503+
}
504+
$tags = array('TAG_1', 'TAG_2', 'TAG_3');
505+
$json_response = json_decode($veryfi_client->add_tags($document_id, $tags), true);
506+
$this->assertNotEmpty($json_response);
507+
}
462508
}

0 commit comments

Comments
 (0)