PaymentStatusRequestTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSend() 0 36 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 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