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

ReceivePaymentRequestTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
B testSend() 0 33 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 ReceivePaymentRequestTest extends \PHPUnit_Framework_TestCase
11
{
12
13
	public function testSend()
14
	{
15
		$postData = [
16
			'payId' => '123456789',
17
			'dttm' => '20140425131559',
18
			'resultCode' => 0,
19
			'resultMessage' => 'OK',
20
			'paymentStatus' => 5,
21
		];
22
23
		$apiClient = $this->getMockBuilder(ApiClient::class)
24
			->disableOriginalConstructor()
25
			->getMock();
26
27
		$apiClient->expects(self::once())->method('createResponseByData')
28
			->with($postData)
29
			->willReturn(
30
				new Response(new ResponseCode(ResponseCode::S200_OK), $postData)
31
			);
32
33
		/** @var ApiClient $apiClient */
34
		$receivePaymentRequest = new ReceivePaymentRequest();
35
36
		$paymentResponse = $receivePaymentRequest->send($apiClient, $postData);
37
38
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
39
		$this->assertSame('123456789', $paymentResponse->getPayId());
40
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
41
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
42
		$this->assertSame('OK', $paymentResponse->getResultMessage());
43
		$this->assertEquals(new PaymentStatus(PaymentStatus::S5_REVOKED), $paymentResponse->getPaymentStatus());
44
		$this->assertNull($paymentResponse->getAuthCode());
45
	}
46
47
}
48