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
![]() |
|||
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 |