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

ClosePaymentRequestTest::testSend()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 26

Duplication

Lines 37
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 37
loc 37
rs 8.8571
cc 1
eloc 26
nc 1
nop 0
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 View Code Duplication
class ClosePaymentRequestTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
13
	public function testSend()
14
	{
15
		$apiClient = $this->getMockBuilder(ApiClient::class)
16
			->disableOriginalConstructor()
17
			->getMock();
18
19
		$apiClient->expects(self::once())->method('put')
20
			->with('payment/close', [
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' => 7,
31
				])
32
			);
33
34
		/** @var ApiClient $apiClient */
35
		$paymentRequest = new ClosePaymentRequest(
36
			'012345',
37
			'123456789'
38
		);
39
40
		$closePaymentResponse = $paymentRequest->send($apiClient);
41
42
		$this->assertInstanceOf(PaymentResponse::class, $closePaymentResponse);
43
		$this->assertSame('123456789', $closePaymentResponse->getPayId());
44
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $closePaymentResponse->getResponseDateTime());
45
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $closePaymentResponse->getResultCode());
46
		$this->assertSame('OK', $closePaymentResponse->getResultMessage());
47
		$this->assertEquals(new PaymentStatus(PaymentStatus::S7_AWAITING_SETTLEMENT), $closePaymentResponse->getPaymentStatus());
48
		$this->assertNull($closePaymentResponse->getAuthCode());
49
	}
50
51
}
52