Completed
Push — master ( 7d5f81...069e15 )
by Jan
02:05
created

StandardFinishRequestTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 45
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSend() 0 40 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway\Call\Masterpass;
4
5
use DateTimeImmutable;
6
use SlevomatCsobGateway\Api\ApiClient;
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
use SlevomatCsobGateway\Call\PaymentResponse;
10
use SlevomatCsobGateway\Call\PaymentStatus;
11
use SlevomatCsobGateway\Call\ResultCode;
12
13
class StandardFinishRequestTest extends \PHPUnit\Framework\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('masterpass/standard/finish', [
24
				'merchantId' => '012345',
25
				'payId' => '123456789',
26
				'oauthToken' => '123456789123456789',
27
				'totalAmount' => 15000,
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
		/** @var ApiClient $apiClient */
40
		$paymentRequest = new StandardFinishRequest(
41
			'012345',
42
			'123456789',
43
			'123456789123456789',
44
			15000
45
		);
46
47
		$checkoutResponse = $paymentRequest->send($apiClient);
48
49
		$this->assertInstanceOf(PaymentResponse::class, $checkoutResponse);
50
		$this->assertSame('123456789', $checkoutResponse->getPayId());
51
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $checkoutResponse->getResponseDateTime());
52
		$this->assertEquals(ResultCode::get(ResultCode::C0_OK), $checkoutResponse->getResultCode());
53
		$this->assertSame('OK', $checkoutResponse->getResultMessage());
54
		$this->assertEquals(PaymentStatus::get(PaymentStatus::S2_IN_PROGRESS), $checkoutResponse->getPaymentStatus());
55
	}
56
57
}
58