Completed
Push — master ( 54bcb1...083d0b )
by Jan
03:06
created

testSendWithStringValues()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 22

Duplication

Lines 32
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 22
c 1
b 0
f 0
nc 1
nop 0
dl 32
loc 32
rs 8.8571
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
class ReceivePaymentRequestTest extends \PHPUnit_Framework_TestCase
11
{
12
13 View Code Duplication
	public function testSend()
0 ignored issues
show
Duplication introduced by
This method 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...
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
			->willReturnCallback(function (array $postData) {
29
				return new Response(new ResponseCode(ResponseCode::S200_OK), $postData);
30
			});
31
32
		/** @var ApiClient $apiClient */
33
		$receivePaymentRequest = new ReceivePaymentRequest();
34
35
		$paymentResponse = $receivePaymentRequest->send($apiClient, $postData);
36
37
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
38
		$this->assertSame('123456789', $paymentResponse->getPayId());
39
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
40
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
41
		$this->assertSame('OK', $paymentResponse->getResultMessage());
42
		$this->assertEquals(new PaymentStatus(PaymentStatus::S5_REVOKED), $paymentResponse->getPaymentStatus());
43
		$this->assertNull($paymentResponse->getAuthCode());
44
	}
45
46 View Code Duplication
	public function testSendWithStringValues()
0 ignored issues
show
Duplication introduced by
This method 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...
47
	{
48
		$postData = [
49
			'payId' => '123456789',
50
			'dttm' => '20140425131559',
51
			'resultCode' => '0',
52
			'resultMessage' => 'OK',
53
			'paymentStatus' => '5',
54
		];
55
56
		$apiClient = $this->getMockBuilder(ApiClient::class)
57
			->disableOriginalConstructor()
58
			->getMock();
59
60
		$apiClient->expects(self::once())->method('createResponseByData')
61
			->willReturnCallback(function (array $postData) {
62
				return new Response(new ResponseCode(ResponseCode::S200_OK), $postData);
63
			});
64
65
		/** @var ApiClient $apiClient */
66
		$receivePaymentRequest = new ReceivePaymentRequest();
67
68
		$paymentResponse = $receivePaymentRequest->send($apiClient, $postData);
69
70
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
71
		$this->assertSame('123456789', $paymentResponse->getPayId());
72
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
73
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
74
		$this->assertSame('OK', $paymentResponse->getResultMessage());
75
		$this->assertEquals(new PaymentStatus(PaymentStatus::S5_REVOKED), $paymentResponse->getPaymentStatus());
76
		$this->assertNull($paymentResponse->getAuthCode());
77
	}
78
79
}
80