Code Duplication    Length = 41-42 lines in 4 locations

tests/unit/Call/ClosePaymentRequestTest.php 1 location

@@ 10-51 (lines=42) @@
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
10
class ClosePaymentRequestTest 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('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

tests/unit/Call/RefundPaymentRequestTest.php 1 location

@@ 10-51 (lines=42) @@
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
10
class RefundPaymentRequestTest 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('put')
20
			->with('payment/refund', [
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' => 8,
31
				])
32
			);
33
34
		/** @var ApiClient $apiClient */
35
		$refundPaymentRequest = new RefundPaymentRequest(
36
			'012345',
37
			'123456789'
38
		);
39
40
		$paymentResponse = $refundPaymentRequest->send($apiClient);
41
42
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
43
		$this->assertSame('123456789', $paymentResponse->getPayId());
44
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
45
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
46
		$this->assertSame('OK', $paymentResponse->getResultMessage());
47
		$this->assertEquals(new PaymentStatus(PaymentStatus::S8_CHARGED), $paymentResponse->getPaymentStatus());
48
		$this->assertNull($paymentResponse->getAuthCode());
49
	}
50
51
}
52

tests/unit/Call/ReversePaymentRequestTest.php 1 location

@@ 10-51 (lines=42) @@
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
10
class ReversePaymentRequestTest 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('put')
20
			->with('payment/reverse', [
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' => 5,
31
				])
32
			);
33
34
		/** @var ApiClient $apiClient */
35
		$reversePaymentRequest = new ReversePaymentRequest(
36
			'012345',
37
			'123456789'
38
		);
39
40
		$paymentResponse = $reversePaymentRequest->send($apiClient);
41
42
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
43
		$this->assertSame('123456789', $paymentResponse->getPayId());
44
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
45
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
46
		$this->assertSame('OK', $paymentResponse->getResultMessage());
47
		$this->assertEquals(new PaymentStatus(PaymentStatus::S5_REVOKED), $paymentResponse->getPaymentStatus());
48
		$this->assertNull($paymentResponse->getAuthCode());
49
	}
50
51
}
52

tests/unit/Call/OneclickStartPaymentRequestTest.php 1 location

@@ 10-50 (lines=41) @@
7
use SlevomatCsobGateway\Api\Response;
8
use SlevomatCsobGateway\Api\ResponseCode;
9
10
class OneclickStartPaymentRequestTest 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('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