PaymentResponseTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_from_json() 0 8 1
A test() 0 10 1
1
<?php
2
/**
3
 * Payment Response Test
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2022 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Payvision
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Payvision;
12
13
/**
14
 * Payment Response Test
15
 *
16
 * @author  Remco Tolsma
17
 * @version 1.1.0
18
 * @since   1.0.0
19
 */
20
class PaymentResponseTest extends \WP_UnitTestCase {
21
	/**
22
	 * Test.
23
	 */
24
	public function test() {
25
		$response_header = new ResponseHeader( '2020-11-10T18:31:20Z' );
26
27
		$payment_response = new PaymentResponse( 2, 'Pending', $response_header );
28
29
		$this->assertInstanceOf( ResponseHeader::class, $response_header );
30
		$this->assertInstanceOf( PaymentResponse::class, $payment_response );
31
		$this->assertEquals( ResultCode::PENDING, $payment_response->get_result() );
32
		$this->assertEquals( 'Pending', $payment_response->get_description() );
33
		$this->assertEquals( $response_header, $payment_response->get_header() );
34
	}
35
36
	/**
37
	 * Test from JSON.
38
	 */
39
	public function test_from_json() {
40
		$json = \file_get_contents( __DIR__ . '/../json/payment-response.json', true );
41
42
		$data = \json_decode( $json );
43
44
		$payment_response = PaymentResponse::from_json( $data );
45
46
		$this->assertEquals( ResultCode::PENDING, $payment_response->get_result() );
47
	}
48
}
49