RefundPaymentRequestTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 25
c 1
b 0
f 0
dl 0
loc 38
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSend() 0 35 1
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 RefundPaymentRequestTest 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/refund', [
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' => 8,
34
				])
35
			);
36
37
		$refundPaymentRequest = new RefundPaymentRequest(
38
			'012345',
39
			'123456789'
40
		);
41
42
		$paymentResponse = $refundPaymentRequest->send($apiClient);
43
44
		self::assertSame('123456789', $paymentResponse->getPayId());
45
		self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
46
		self::assertEquals(ResultCode::get(ResultCode::C0_OK), $paymentResponse->getResultCode());
47
		self::assertSame('OK', $paymentResponse->getResultMessage());
48
		self::assertEquals(PaymentStatus::get(PaymentStatus::S8_CHARGED), $paymentResponse->getPaymentStatus());
49
		self::assertNull($paymentResponse->getAuthCode());
50
	}
51
52
}
53