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 ClosePaymentRequestTest 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('put') |
23
|
|
|
->with('payment/close', [ |
24
|
|
|
'merchantId' => '012345', |
25
|
|
|
'payId' => '123456789', |
26
|
|
|
'totalAmount' => 987, |
27
|
|
|
]) |
28
|
|
|
->willReturn( |
29
|
|
|
new Response(ResponseCode::get(ResponseCode::S200_OK), [ |
30
|
|
|
'payId' => '123456789', |
31
|
|
|
'dttm' => '20140425131559', |
32
|
|
|
'resultCode' => 0, |
33
|
|
|
'resultMessage' => 'OK', |
34
|
|
|
'paymentStatus' => 7, |
35
|
|
|
]) |
36
|
|
|
); |
37
|
|
|
|
38
|
|
|
$paymentRequest = new ClosePaymentRequest( |
39
|
|
|
'012345', |
40
|
|
|
'123456789', |
41
|
|
|
987 |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
$closePaymentResponse = $paymentRequest->send($apiClient); |
45
|
|
|
|
46
|
|
|
self::assertSame('123456789', $closePaymentResponse->getPayId()); |
47
|
|
|
self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $closePaymentResponse->getResponseDateTime()); |
48
|
|
|
self::assertEquals(ResultCode::get(ResultCode::C0_OK), $closePaymentResponse->getResultCode()); |
49
|
|
|
self::assertSame('OK', $closePaymentResponse->getResultMessage()); |
50
|
|
|
self::assertEquals(PaymentStatus::get(PaymentStatus::S7_AWAITING_SETTLEMENT), $closePaymentResponse->getPaymentStatus()); |
51
|
|
|
self::assertNull($closePaymentResponse->getAuthCode()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
} |
55
|
|
|
|