StartOneClickPaymentRequestTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSend() 0 35 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway\Call\OneClick;
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
use SlevomatCsobGateway\Call\PaymentStatus;
12
use SlevomatCsobGateway\Call\ResultCode;
13
14
class StartOneClickPaymentRequestTest extends TestCase
15
{
16
17
	public function testSend(): void
18
	{
19
		/** @var ApiClient|MockObject $apiClient */
20
		$apiClient = $this->getMockBuilder(ApiClient::class)
21
			->disableOriginalConstructor()
22
			->getMock();
23
24
		$apiClient->expects(self::once())->method('post')
25
			->with('oneclick/start', [
26
				'merchantId' => '012345',
27
				'payId' => 'ef08b6e9f22345c',
28
			])
29
			->willReturn(
30
				new Response(ResponseCode::get(ResponseCode::S200_OK), [
31
					'payId' => '123456789',
32
					'dttm' => '20140425131559',
33
					'resultCode' => 0,
34
					'resultMessage' => 'OK',
35
					'paymentStatus' => 2,
36
				])
37
			);
38
39
		$initPaymentRequest = new StartOneClickPaymentRequest(
40
			'012345',
41
			'ef08b6e9f22345c'
42
		);
43
44
		$paymentResponse = $initPaymentRequest->send($apiClient);
45
46
		self::assertSame('123456789', $paymentResponse->getPayId());
47
		self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
48
		self::assertEquals(ResultCode::get(ResultCode::C0_OK), $paymentResponse->getResultCode());
49
		self::assertSame('OK', $paymentResponse->getResultMessage());
50
		self::assertEquals(PaymentStatus::get(PaymentStatus::S2_IN_PROGRESS), $paymentResponse->getPaymentStatus());
51
		self::assertNull($paymentResponse->getAuthCode());
52
	}
53
54
}
55