Passed
Push — main ( 061772...28b955 )
by Remco
07:49 queued 12s
created

ErrorTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test() 0 13 1
A test_from_json() 0 10 1
1
<?php
2
/**
3
 * Error Test
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2020 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
 * Error Test
15
 *
16
 * @author  Remco Tolsma
17
 * @version 1.0.0
18
 * @since   1.0.0
19
 */
20
class ErrorTest extends \WP_UnitTestCase {
21
	/**
22
	 * Test.
23
	 */
24
	public function test() {
25
		$error = new Error(
26
			1004,
27
			'Property not found in request: body.card.number.',
28
			'Property not found in request: body.card.number.'
29
		);
30
31
		$this->assertInstanceOf( Error::class, $error );
32
		$this->assertEquals( 1004, $error->getCode() );
33
		$this->assertEquals( 1004, $error->get_code() );
34
		$this->assertEquals( 'Property not found in request: body.card.number.', $error->getMessage() );
35
		$this->assertEquals( 'Property not found in request: body.card.number.', $error->get_message() );
36
	}
37
38
	/**
39
	 * Test from JSON.
40
	 */
41
	public function test_from_json() {
42
		$json = \file_get_contents( __DIR__ . '/../json/error.json', true );
43
44
		$data = \json_decode( $json );
45
46
		$error = Error::from_json( $data );
47
48
		$this->assertEquals( 1004, $error->getCode() );
49
		$this->assertEquals( 'Property not found in request: body.card.number.', $error->getMessage() );
50
	}
51
}
52