forked from Easy-Forex/PHP-Compare-Advanced-Sets
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVersionComparisonTest.php
99 lines (94 loc) · 2.74 KB
/
VersionComparisonTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
require_once 'VersionComparison.php';
class VersionComparisonTest extends PHPUnit_Framework_TestCase {
/**
* Version List Provider
*
* Provides List Array with Groups and Item : Version test information
*/
public function version_provider(){
return array(
// Same Packages Installed on both Servers
array(
// List Array
// Group => {"Item":"Version"}
array(
'Server-1' => '{"Package1":"1.8.1","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.9","Package5":"2.1.31"}',
'Server-2' => '{"Package1":"1.8.1","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.9","Package5":"2.1.31"}',
),
// Expected Result
array(
'Server-2' => array(
'missing' => array(),
'different' => array(),
'extra' => array()
),
),
),
// Same Packages Installed on both Servers but with Different Versions
array(
// List Array
// Group => {"Item":"Version"}
array(
'Server-1' => '{"Package1":"1.8.1","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.9","Package5":"2.1.31"}',
'Server-2' => '{"Package1":"1.8.0","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.8","Package5":"2.1.31"}',
),
// Expected Result
array(
'Server-2' => array(
'missing' => array(),
'different' => array(
"Package1" => "1.8.1",
"Package4" => "0.9",
),
'extra' => array()
),
),
),
// Certain Packages Not Installed in Server-2
array(
// List Array
// Group => {"Item":"Version"}
array(
'Server-1' => '{"Package1":"1.8.1","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.9","Package5":"2.1.31"}',
'Server-2' => '{"Package1":"1.8.1","Package4":"0.9","Package5":"2.1.31"}',
),
// Expected Result
array(
'Server-2' => array(
'missing' => array("Package2","Package3"),
'different' => array(),
'extra' => array(),
),
),
),
// Extra Packages Installed in Server-2
array(
// List Array
// Group => {"Item":"Version"}
array(
'Server-1' => '{"Package1":"1.8.1","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.9","Package5":"2.1.31"}',
'Server-2' => '{"Package1":"1.8.1","Package2":"1.0.22","Package3":"1.1.4","Package4":"0.9","Package5":"2.1.31","extra-Package":"1.0.0"}',
),
// Expected Result
array(
'Server-2' => array(
'missing' => array(),
'different' => array(),
'extra' => array("extra-Package")
),
),
),
);
}
/**
* Test Compare Version
*
* @dataProvider version_provider
*/
public function test__CompareVersion($list_array, $expected_result){
$actual_result = VersionComparison::CompareVersions($list_array);
$this->assertEquals($expected_result, $actual_result);
}
}
?>