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/Oneclick/StartPaymentRequestTest.php 1 location

@@ 13-53 (lines=41) @@
10
use SlevomatCsobGateway\Call\PaymentStatus;
11
use SlevomatCsobGateway\Call\ResultCode;
12
13
class StartPaymentRequestTest extends \PHPUnit_Framework_TestCase
14
{
15
16
	public function testSend()
17
	{
18
		$apiClient = $this->getMockBuilder(ApiClient::class)
19
			->disableOriginalConstructor()
20
			->getMock();
21
22
		$apiClient->expects(self::once())->method('post')
23
			->with('payment/oneclick/start', [
24
				'merchantId' => '012345',
25
				'payId' => 'ef08b6e9f22345c',
26
			])
27
			->willReturn(
28
				new Response(new ResponseCode(ResponseCode::S200_OK), [
29
					'payId' => '123456789',
30
					'dttm' => '20140425131559',
31
					'resultCode' => 0,
32
					'resultMessage' => 'OK',
33
					'paymentStatus' => 2,
34
				])
35
			);
36
37
		$initPaymentRequest = new StartPaymentRequest(
38
			'012345',
39
			'ef08b6e9f22345c'
40
		);
41
42
		$paymentResponse = $initPaymentRequest->send($apiClient);
43
44
		$this->assertInstanceOf(PaymentResponse::class, $paymentResponse);
45
		$this->assertSame('123456789', $paymentResponse->getPayId());
46
		$this->assertEquals(DateTimeImmutable::createFromFormat('YmdHis', '20140425131559'), $paymentResponse->getResponseDateTime());
47
		$this->assertEquals(new ResultCode(ResultCode::C0_OK), $paymentResponse->getResultCode());
48
		$this->assertSame('OK', $paymentResponse->getResultMessage());
49
		$this->assertEquals(new PaymentStatus(PaymentStatus::S2_IN_PROGRESS), $paymentResponse->getPaymentStatus());
50
		$this->assertNull($paymentResponse->getAuthCode());
51
	}
52
53
}
54