1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace SlevomatCsobGateway\Call; |
4
|
|
|
|
5
|
|
|
use DateTimeImmutable; |
6
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
use SlevomatCsobGateway\Api\ApiClient; |
9
|
|
|
use SlevomatCsobGateway\Api\Response; |
10
|
|
|
use SlevomatCsobGateway\Api\ResponseCode; |
11
|
|
|
|
12
|
|
|
class PaymentStatusRequestTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
public function testSend(): void |
16
|
|
|
{ |
17
|
|
|
/** @var ApiClient|MockObject $apiClient */ |
18
|
|
|
$apiClient = $this->getMockBuilder(ApiClient::class) |
19
|
|
|
->disableOriginalConstructor() |
20
|
|
|
->getMock(); |
21
|
|
|
|
22
|
|
|
$apiClient->expects(self::once())->method('get') |
23
|
|
|
->with('payment/status/{merchantId}/{payId}/{dttm}/{signature}', [ |
24
|
|
|
'merchantId' => '012345', |
25
|
|
|
'payId' => '123456789', |
26
|
|
|
]) |
27
|
|
|
->willReturn( |
28
|
|
|
new Response(ResponseCode::get(ResponseCode::S200_OK), [ |
29
|
|
|
'payId' => '123456789', |
30
|
|
|
'dttm' => '20140425131559', |
31
|
|
|
'resultCode' => 0, |
32
|
|
|
'resultMessage' => 'OK', |
33
|
|
|
'paymentStatus' => 4, |
34
|
|
|
'authCode' => 'F7A23E', |
35
|
|
|
]) |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$paymentStatusRequest = new PaymentStatusRequest( |
39
|
|
|
'012345', |
40
|
|
|
'123456789' |
41
|
|
|
); |
42
|
|
|
|
43
|
|
|
$paymentResponse = $paymentStatusRequest->send($apiClient); |
44
|
|
|
|
45
|
|
|
self::assertSame('123456789', $paymentResponse->getPayId()); |
46
|
|
|
self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime()); |
47
|
|
|
self::assertEquals(ResultCode::get(ResultCode::C0_OK), $paymentResponse->getResultCode()); |
48
|
|
|
self::assertSame('OK', $paymentResponse->getResultMessage()); |
49
|
|
|
self::assertEquals(PaymentStatus::get(PaymentStatus::S4_CONFIRMED), $paymentResponse->getPaymentStatus()); |
50
|
|
|
self::assertSame('F7A23E', $paymentResponse->getAuthCode()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
} |
54
|
|
|
|