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

OneclickStartPaymentRequestTest::testSend()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 36
Code Lines 26

Duplication

Lines 36
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 26
nc 1
nop 0
dl 36
loc 36
rs 8.8571
c 1
b 0
f 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
10 View Code Duplication
class OneclickStartPaymentRequestTest 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('post')
20
			->with('payment/oneclick/start', [
21
				'merchantId' => '012345',
22
				'payId' => 'ef08b6e9f22345c',
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' => 2,
31
				])
32
			);
33
34
		$initPaymentRequest = new OneclickStartPaymentRequest(
35
			'012345',
36
			'ef08b6e9f22345c'
37
		);
38
39
		$paymentResponse = $initPaymentRequest->send($apiClient);
40
41
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
42
		$this->assertSame('123456789', $paymentResponse->getPayId());
43
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
44
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
45
		$this->assertSame('OK', $paymentResponse->getResultMessage());
46
		$this->assertEquals(new PaymentStatus(PaymentStatus::S2_IN_PROGRESS), $paymentResponse->getPaymentStatus());
47
		$this->assertNull($paymentResponse->getAuthCode());
48
	}
49
50
}
51