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

StartOneClickPaymentRequestTest::testSend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 34
rs 9.536
c 0
b 0
f 0
cc 1
nc 1
nop 0
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\PaymentStatus;
11
use SlevomatCsobGateway\Call\ResultCode;
12
13
class StartOneClickPaymentRequestTest extends TestCase
14
{
15
16
	public function testSend(): void
17
	{
18
		$apiClient = $this->getMockBuilder(ApiClient::class)
19
			->disableOriginalConstructor()
20
			->getMock();
21
22
		$apiClient->expects(self::once())->method('post')
23
			->with('oneclick/start', [
24
				'merchantId' => '012345',
25
				'payId' => 'ef08b6e9f22345c',
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' => 2,
34
				])
35
			);
36
37
		$initPaymentRequest = new StartOneClickPaymentRequest(
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
		self::assertEquals(PaymentStatus::get(PaymentStatus::S2_IN_PROGRESS), $paymentResponse->getPaymentStatus());
49
		self::assertNull($paymentResponse->getAuthCode());
50
	}
51
52
}
53