feat(accounting): add Shayegan as fixed boursecu provider
Wire outbound Invoice/Document sync after confirmed ops, store sync status with timeout lock, and keep SQL credentials out of frontend responses. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Services\ShayeganClient;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionMethod;
|
||||
|
||||
class ShayeganClientErrorMessageTest extends TestCase
|
||||
{
|
||||
public function test_extract_error_message_from_top_level(): void
|
||||
{
|
||||
$client = $this->clientWithoutConstruct();
|
||||
$method = new ReflectionMethod(ShayeganClient::class, 'extractErrorMessage');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$msg = $method->invoke($client, [
|
||||
'ErrorMessage' => 'missing account',
|
||||
'Result' => [['ErrorMessage' => '', 'Number' => '1']],
|
||||
]);
|
||||
|
||||
$this->assertSame('missing account', $msg);
|
||||
}
|
||||
|
||||
public function test_extract_error_message_from_result_row(): void
|
||||
{
|
||||
$client = $this->clientWithoutConstruct();
|
||||
$method = new ReflectionMethod(ShayeganClient::class, 'extractErrorMessage');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$msg = $method->invoke($client, [
|
||||
'ErrorMessage' => '',
|
||||
'Result' => [['ErrorMessage' => 'row failed', 'Number' => null]],
|
||||
]);
|
||||
|
||||
$this->assertSame('row failed', $msg);
|
||||
}
|
||||
|
||||
public function test_empty_error_message_is_success_signal(): void
|
||||
{
|
||||
$client = $this->clientWithoutConstruct();
|
||||
$method = new ReflectionMethod(ShayeganClient::class, 'extractErrorMessage');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$msg = $method->invoke($client, [
|
||||
'ErrorMessage' => '',
|
||||
'Result' => [['ErrorMessage' => '', 'Number' => '12', 'GuId' => 'abc']],
|
||||
]);
|
||||
|
||||
$this->assertSame('', $msg);
|
||||
}
|
||||
|
||||
private function clientWithoutConstruct(): ShayeganClient
|
||||
{
|
||||
return (new \ReflectionClass(ShayeganClient::class))->newInstanceWithoutConstructor();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user