Completed
Push — master ( b59c0c...c68fa7 )
by Josef
08:24
created

OneclickInitPaymentRequestTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 49
rs 10
c 1
b 0
f 1
wmc 1
lcom 1
cbo 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSend() 0 44 1
1
<?php declare(strict_types = 1);
2
3
namespace SlevomatCsobGateway\Call;
4
5
use DateTimeImmutable;
6
use SlevomatCsobGateway\Api\ApiClient;
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
use SlevomatCsobGateway\Currency;
10
use SlevomatCsobGateway\Price;
11
12
class OneclickInitPaymentRequestTest extends \PHPUnit_Framework_TestCase
13
{
14
15
	public function testSend()
16
	{
17
		$apiClient = $this->getMockBuilder(ApiClient::class)
18
			->disableOriginalConstructor()
19
			->getMock();
20
21
		$apiClient->expects(self::once())->method('post')
22
			->with('payment/oneclick/init', [
23
				'merchantId' => '012345',
24
				'origPayId' => 'ef08b6e9f22345c',
25
				'orderNo' => '5547',
26
				'totalAmount' => 1789600,
27
				'currency' => 'CZK',
28
				'description' => 'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)',
29
			])
30
			->willReturn(
31
				new Response(new ResponseCode(ResponseCode::S200_OK), [
32
					'payId' => '123456789',
33
					'dttm' => '20140425131559',
34
					'resultCode' => 0,
35
					'resultMessage' => 'OK',
36
					'paymentStatus' => 1,
37
				])
38
			);
39
40
		$initPaymentRequest = new OneclickInitPaymentRequest(
41
			'012345',
42
			'ef08b6e9f22345c',
43
			'5547',
44
			new Price(1789600, new Currency(Currency::CZK)),
45
			'Nákup na vasobchod.cz (Lenovo ThinkPad Edge E540, Doprava PPL)'
46
		);
47
48
		/** @var ApiClient $apiClient */
49
		$paymentResponse = $initPaymentRequest->send($apiClient);
50
51
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
52
		$this->assertSame('123456789', $paymentResponse->getPayId());
53
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
54
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
55
		$this->assertSame('OK', $paymentResponse->getResultMessage());
56
		$this->assertEquals(new PaymentStatus(PaymentStatus::S1_CREATED), $paymentResponse->getPaymentStatus());
57
		$this->assertNull($paymentResponse->getAuthCode());
58
	}
59
60
}
61