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(); } }