Completed
Pull Request — master (#5)
by Jan
06:16 queued 02:12
created

testFormatDataForSignature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
namespace SlevomatCsobGateway\Crypto;
4
5
class SignatureDataFormatterTest extends \PHPUnit_Framework_TestCase
6
{
7
8
	/**
9
	 * @return mixed[]
10
	 */
11
	public function getFormatDataForSignatureData()
12
	{
13
		return [
14
			[
15
				[
16
					'id' => null,
17
					'name' => null,
18
				],
19
				[
20
					'id' => 123,
21
					'name' => 'foo',
22
				],
23
				'123|foo',
24
			],
25
			[
26
				[
27
					'id' => null,
28
					'name' => null,
29
				],
30
				[
31
					'name' => 'foo',
32
					'id' => 123,
33
				],
34
				'123|foo',
35
			],
36
			[
37
				[
38
					'id' => null,
39
					'name' => null,
40
				],
41
				[
42
					'name' => 'foo',
43
					'id' => 123,
44
					'date' => '2015-10-10',
45
				],
46
				'123|foo',
47
			],
48
			[
49
				[
50
					'id' => null,
51
					'name' => null,
52
					'date' => null,
53
				],
54
				[
55
					'name' => 'foo',
56
					'id' => 123,
57
				],
58
				'123|foo',
59
			],
60
			[
61
				[
62
					'id' => null,
63
					'name' => null,
64
					'cart' => [
65
						'name' => null,
66
						'price' => null,
67
					],
68
					'description' => null,
69
				],
70
				[
71
					'name' => 'foo',
72
					'id' => 123,
73
					'cart' => [
74
						[
75
							'price' => 99,
76
							'name' => 'foo product',
77
						],
78
						[
79
							'name' => 'bar product',
80
						],
81
					],
82
					'description' => 'order description',
83
				],
84
				'123|foo|foo product|99|bar product|order description',
85
			],
86
		];
87
	}
88
89
	/**
90
	 * @param mixed[] $keyPriority
91
	 * @param mixed[] $data
92
	 * @param string $expectedData
93
	 *
94
	 * @dataProvider getFormatDataForSignatureData
95
	 */
96
	public function testFormatDataForSignature(array $keyPriority, array $data, $expectedData)
97
	{
98
		$signatureDataFormatter = new SignatureDataFormatter($keyPriority);
99
100
		$this->assertSame($expectedData, $signatureDataFormatter->formatDataForSignature($data));
101
	}
102
103
}
104