Failed Conditions
Push — master ( ef4611...12f600 )
by Remco
11:54 queued 05:55
created

ClientTest::test_signature_in_empty()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Ingenico\OrderStandard;
4
5
use Pronamic\WordPress\Pay\Gateways\Ingenico\DataGeneralHelper;
6
7
/**
8
 * Title: Ogone client class test
9
 * Description:
10
 * Copyright: 2005-2019 Pronamic
11
 * Company: Pronamic
12
 *
13
 * @author  Remco Tolsma
14
 * @version 2.0.0
15
 * @since   1.1.0
16
 */
17
class ClientTest extends \WP_UnitTestCase {
18
	/**
19
	 * Test signature in empty.
20
	 */
21
	public function test_signature_in_empty() {
22
		$client = new Client( '' );
23
24
		$signature_in = $client->get_signature_in();
25
26
		$this->assertEquals( 'DA39A3EE5E6B4B0D3255BFEF95601890AFD80709', $signature_in );
27
	}
28
29
	/**
30
	 * Test signature in from documentation.
31
	 */
32
	public function test_signature_in_from_documentation() {
33
		/* @link http://pronamic.nl/wp-content/uploads/2012/02/ABNAMRO_e-Com-BAS_EN.pdf #page 11 */
34
		$client = new Client( 'MyPSPID' );
35
36
		$client->set_pass_phrase_in( 'Mysecretsig1875!?' );
37
38
		// Data.
39
		$ogone_data = $client->get_data();
40
41
		// General.
42
		$ogone_data_general = new DataGeneralHelper( $ogone_data );
43
44
		$ogone_data_general
45
			->set_amount( 1500 )
46
			->set_currency( 'EUR' )
47
			->set_language( 'en_US' )
48
			->set_order_id( '1234' );
49
50
		// Signature.
51
		$signature_in = $client->get_signature_in();
52
53
		$this->assertEquals( 'F4CC376CD7A834D997B91598FA747825A238BE0A', $signature_in );
54
	}
55
56
	/**
57
	 * Test signature out from documentation.
58
	 */
59
	public function test_signature_out_from_documentation() {
60
		/* @link http://pronamic.nl/wp-content/uploads/2012/02/ABNAMRO_e-Com-BAS_EN.pdf #page 16 */
61
		$data = array(
62
			'ACCEPTANCE' => '1234',
63
			'AMOUNT'     => '15.00',
64
			'BRAND'      => 'VISA',
65
			'CARDNO'     => 'xxxxxxxxxxxx1111',
66
			'CURRENCY'   => 'EUR',
67
			'NCERROR'    => '0',
68
			'ORDERID'    => '12',
69
			'PAYID'      => '32100123',
70
			'PM'         => 'CreditCard',
71
			'STATUS'     => '9',
72
			'SHASIGN'    => '8DC2A769700CA4B3DF87FE8E3B6FD162D6F6A5FA',
73
		);
74
75
		$client = new Client( 'MyPSPID' );
76
77
		$client->set_pass_phrase_out( 'Mysecretsig1875!?' );
78
79
		$result = $client->verify_request( $data );
80
81
		$this->assertNotSame( false, $result );
82
	}
83
}
84