Failed Conditions
Push — master ( 43b4b7...4826e1 )
by Remco
13:45 queued 08:11
created

SignatureSortingTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A test_signature_sorting() 0 27 1
1
<?php
2
3
namespace Pronamic\WordPress\Pay\Gateways\Buckaroo;
4
5
/**
6
 * Title: Buckaroo signature sorting test.
7
 * Description:
8
 * Copyright: 2005-2019 Pronamic
9
 * Company: Pronamic
10
 *
11
 * @link http://pronamic.nl/wp-content/uploads/2013/04/BPE-3.0-Gateway-HTML.1.02.pdf
12
 * @author Remco Tolsma
13
 * @version 2.0.0
14
 */
15
class SignatureSortingTest extends \WP_UnitTestCase {
16
	/**
17
	 * Test signature sorting.
18
	 */
19
	public function test_signature_sorting() {
20
		/**
21
		 * Sort these parameters alphabetically on the parameter name (brq_amount comes before brq_websitekey).
22
		 *
23
		 * Note: sorting must be case insensitive (brq_active comes before BRQ_AMOUNT) but casing in parameter names and values must be preserved.
24
		 */
25
		$data = array(
26
			'brq_websitekey' => '123456',
27
			'BRQ_AMOUNT'     => '25.00',
28
			'brq_active'     => 'true',
29
		);
30
31
		$expected = array(
32
			'brq_active'     => 'true',
33
			'BRQ_AMOUNT'     => '25.00',
34
			'brq_websitekey' => '123456',
35
		);
36
37
		// Sort
38
		$data = Security::sort( $data );
39
40
		// Keys
41
		$keys_data     = implode( "\n", array_keys( $data ) );
42
		$keys_expected = implode( "\n", array_keys( $expected ) );
43
44
		// Assert
45
		$this->assertEquals( $keys_expected, $keys_data );
46
	}
47
}
48