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>
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?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();
|
|
}
|
|
}
|