Completed
Push — master ( 955097...f4414e )
by Jan
08:34
created

OneClickEchoRequestTest   A

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\TestCase;
7
use SlevomatCsobGateway\Api\ApiClient;
8
use SlevomatCsobGateway\Api\Response;
9
use SlevomatCsobGateway\Api\ResponseCode;
10
use SlevomatCsobGateway\Call\ResultCode;
11
12
class OneClickEchoRequestTest extends TestCase
13
{
14
15
	public function testSend(): void
16
	{
17
		$apiClient = $this->getMockBuilder(ApiClient::class)
18
			->disableOriginalConstructor()
19
			->getMock();
20
21
		$apiClient->expects(self::once())->method('post')
22
			->with('oneclick/echo', [
23
				'merchantId' => '012345',
24
				'origPayId' => 'ef08b6e9f22345c',
25
			])
26
			->willReturn(
27
				new Response(ResponseCode::get(ResponseCode::S200_OK), [
28
					'origPayId' => '123456789',
29
					'dttm' => '20140425131559',
30
					'resultCode' => 0,
31
					'resultMessage' => 'OK',
32
				])
33
			);
34
35
		$initPaymentRequest = new OneClickEchoRequest(
36
			'012345',
37
			'ef08b6e9f22345c'
38
		);
39
40
		/** @var ApiClient $apiClient */
41
		$paymentResponse = $initPaymentRequest->send($apiClient);
42
43
		self::assertSame('123456789', $paymentResponse->getPayId());
44
		self::assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
45
		self::assertEquals(ResultCode::get(ResultCode::C0_OK), $paymentResponse->getResultCode());
46
		self::assertSame('OK', $paymentResponse->getResultMessage());
47
	}
48
49
}
50