/
versionCheck.php
133 lines (127 loc) · 4.02 KB
/
versionCheck.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
include('versionComparator.php');
$vc = new versionComparator();
$versions = array(
array('1.-1', '1', '-1'),
array('1', '1.', '0'),
array('1.', '1.0', '0'),
array('1.0', '1.0.0', '0'),
array('1.0.0', '1.1a', '-1'),
array('1.1a', '1.1aa', '-1'),
array('1.1aa', '1.1ab', '-1'),
array('1.1ab', '1.1b', '-1'),
array('1.1b', '1.1c', '-1'),
array('1.1c', '1.1pre', '-1'),
array('1.1pre', '1.1pre0', '0'),
array('1.1pre0', '1.0+', '0'),
array('1.0+', '1.1pre1a', '-1'),
array('1.1pre1a', '1.1pre1aa', '-1'),
array('1.1pre1aa', '1.1pre1b', '-1'),
array('1.1pre1b', '1.1pre1', '-1'),
array('1.1pre1', '1.1pre2', '-1'),
array('1.1pre2', '1.1pre10', '-1'),
array('1.1pre10', '1.1.-1', '-1'),
array('1.1.-1', '1.1', '-1'),
array('1.1', '1.1.0', '0'),
array('1.1.0', '1.1.00', '0'),
array('1.1.00', '1.10', '-1'),
array('1.10', '1.*', '-1'),
array('1.*', '1.*.1', '-1'),
array('1.*.1', '2.0', '-1'),
array('1', '1.-1', '1'),
array('1.', '1', '0'),
array('1.0', '1.', '0'),
array('1.0.0', '1.0', '0'),
array('1.1a', '1.0.0', '1'),
array('1.1aa', '1.1a', '1'),
array('1.1ab', '1.1aa', '1'),
array('1.1b', '1.1ab', '1'),
array('1.1c', '1.1b', '1'),
array('1.1pre', '1.1c', '1'),
array('1.1pre0', '1.1pre', '0'),
array('1.0+', '1.1pre0', '0'),
array('1.1pre1a', '1.0+', '1'),
array('1.1pre1aa', '1.1pre1a', '1'),
array('1.1pre1b', '1.1pre1aa', '1'),
array('1.1pre1', '1.1pre1b', '1'),
array('1.1pre2', '1.1pre1', '1'),
array('1.1pre10', '1.1pre2', '1'),
array('1.1.-1', '1.1pre10', '1'),
array('1.1', '1.1.-1', '1'),
array('1.1.0', '1.1', '0'),
array('1.1.00', '1.1.0', '0'),
array('1.10', '1.1.00', '1'),
array('1.*', '1.10', '1'),
array('1.*.1', '1.*', '1'),
array('2.0', '1.*.1', '1')
);
?>
<!DOCTYPE html>
<html>
<head>
<title>Version Comparison Test Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="https://getfirebug.com/tests/content/templates/default/testcase.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
table {
width: 350px;
}
td:nth-child(-n+2) {
text-align: right;
}
td:nth-last-child(-n+2) {
text-align: center;
}
td.correct {
background: -moz-linear-gradient(135deg, #78FF8C, #B4FFC8);
}
td.wrong {
background: -moz-linear-gradient(135deg, #FF8C78, #FFC8B4);
}
</style>
</head>
<body>
<header>
<h1>Version Comparison Test Page</h1>
</header>
<div>
<section id="description">
<table>
<tr>
<th>Version 1</th>
<th>Version 2</th>
<th>Expected</th>
<th>Result</th>
</tr>
<?php
$wrongResults = 0;
foreach($versions as $version)
{
$comparisonResult = $vc->compareVersions($version[0], $version[1]);
$comparisonCorrect = ($comparisonResult == $version[2]);
if (!$comparisonCorrect)
$wrongResults++;
echo '<tr>'.
' <td>'.$version[0].'</td>'.
' <td>'.$version[1].'</td>'.
' <td>'.$version[2].'</td>'.
' <td class="'.($comparisonCorrect ? 'correct' : 'wrong').'">'.$comparisonResult.'</td>'.
'</tr>';
}
echo '<tr>'.
' <td>6.*</td>'.
' <td>'.$vc->userAgent['userAgentVersion'].' <em>(UA version)</em></td>'.
' <td> </td>'.
' <td>'.$vc->compareWithUserAgentVersion('6.*').'</td>'.
'</tr>'.
'<tr>'.
' <td colspan="3">Wrong results</td>'.
' <td>'.$wrongResults.'</td>'.
'</tr>';
?>
</table>
</section>
<footer>Sebastian Zartner</footer>
</div>
</body>
</html>