IntegrationTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 21
c 2
b 0
f 0
dl 0
loc 51
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A test_config_post() 0 22 1
A setUp() 0 4 1
A test_settings_fields() 0 4 1
1
<?php
2
/**
3
 * Integration 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
 * Integration test
15
 *
16
 * @author  Remco Tolsma
17
 * @version 1.1.0
18
 * @since   1.0.0
19
 */
20
class IntegrationTest extends \WP_UnitTestCase {
21
	/**
22
	 * Integration.
23
	 *
24
	 * @var Integration
25
	 */
26
	private $integration;
27
28
	/**
29
	 * Setup.
30
	 */
31
	public function setUp() {
32
		parent::setUp();
33
34
		$this->integration = new Integration();
35
	}
36
37
	/**
38
	 * Test settings fields.
39
	 */
40
	public function test_settings_fields() {
41
		$fields = $this->integration->get_settings_fields();
42
43
		$this->assertCount( 5, $fields );
44
	}
45
46
	/**
47
	 * Test config / gateway.
48
	 */
49
	public function test_config_post() {
50
		$post_id = $this->factory->post->create();
0 ignored issues
show
Bug Best Practice introduced by
The property factory does not exist on Pronamic\WordPress\Pay\G...yvision\IntegrationTest. Since you implemented __get, consider adding a @property annotation.
Loading history...
51
52
		\update_post_meta( $post_id, '_pronamic_gateway_mode', Gateway::MODE_TEST );
53
		\update_post_meta( $post_id, '_pronamic_gateway_payvision_business_id', '123456' );
54
		\update_post_meta( $post_id, '_pronamic_gateway_payvision_username', 'Test' );
55
		\update_post_meta( $post_id, '_pronamic_gateway_payvision_password', '●●●●●●●●' );
56
		\update_post_meta( $post_id, '_pronamic_gateway_payvision_store_id', '1' );
57
58
		$config = $this->integration->get_config( $post_id );
59
60
		$this->assertInstanceOf( Config::class, $config );
61
		$this->assertEquals( '123456', $config->get_business_id() );
62
		$this->assertEquals( '1', $config->get_store_id() );
63
		$this->assertEquals(
64
			'{"mode":"test","business_id":"123456","username":"Test","password":"\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf\u25cf","store_id":"1"}',
65
			\wp_json_encode( $config )
66
		);
67
68
		$gateway = $this->integration->get_gateway( $post_id );
69
70
		$this->assertInstanceOf( Gateway::class, $gateway );
71
	}
72
}
73