Completed
Push — master ( 170fde...562033 )
by Jan
03:08
created

PaymentStatusRequestTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSend() 0 38 1
1
<?php
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
10
class PaymentStatusRequestTest extends \PHPUnit_Framework_TestCase
11
{
12
13
	public function testSend()
14
	{
15
		$apiClient = $this->getMockBuilder(ApiClient::class)
16
			->disableOriginalConstructor()
17
			->getMock();
18
19
		$apiClient->expects(self::once())->method('get')
20
			->with('payment/status/{merchantId}/{payId}/{dttm}/{signature}', [
21
				'merchantId' => '012345',
22
				'payId' => '123456789',
23
			])
24
			->willReturn(
25
				new Response(new ResponseCode(ResponseCode::S200_OK), [
26
					'payId' => '123456789',
27
					'dttm' => '20140425131559',
28
					'resultCode' => 0,
29
					'resultMessage' => 'OK',
30
					'paymentStatus' => 4,
31
					'authCode' => 'F7A23E',
32
				])
33
			);
34
35
		/** @var ApiClient $apiClient */
36
		$paymentStatusRequest = new PaymentStatusRequest(
37
			'012345',
38
			'123456789'
39
		);
40
41
		$paymentResponse = $paymentStatusRequest->send($apiClient);
42
43
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
44
		$this->assertSame('123456789', $paymentResponse->getPayId());
45
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
46
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
47
		$this->assertSame('OK', $paymentResponse->getResultMessage());
48
		$this->assertEquals(new PaymentStatus(PaymentStatus::S4_CONFIRMED), $paymentResponse->getPaymentStatus());
49
		$this->assertSame('F7A23E', $paymentResponse->getAuthCode());
50
	}
51
52
}
53