OneClickEchoRequestTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSend() 0 32 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\ResultCode;
12
13
class OneClickEchoRequestTest extends TestCase
14
{
15
16
	public function testSend(): void
17
	{
18
		/** @var ApiClient|MockObject $apiClient */
19
		$apiClient = $this->getMockBuilder(ApiClient::class)
20
			->disableOriginalConstructor()
21
			->getMock();
22
23
		$apiClient->expects(self::once())->method('post')
24
			->with('oneclick/echo', [
25
				'merchantId' => '012345',
26
				'origPayId' => 'ef08b6e9f22345c',
27
			])
28
			->willReturn(
29
				new Response(ResponseCode::get(ResponseCode::S200_OK), [
30
					'origPayId' => '123456789',
31
					'dttm' => '20140425131559',
32
					'resultCode' => 0,
33
					'resultMessage' => 'OK',
34
				])
35
			);
36
37
		$initPaymentRequest = new OneClickEchoRequest(
38
			'012345',
39
			'ef08b6e9f22345c'
40
		);
41
42
		$paymentResponse = $initPaymentRequest->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
	}
49
50
}
51