-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
php-version.spec.js
76 lines (69 loc) · 2.35 KB
/
php-version.spec.js
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
'use strict'
const { test, given } = require('sazerac')
const { compare, minorVersion, versionReduction } = require('./php-version')
const phpReleases = [
'5.0',
'5.1',
'5.2',
'5.3',
'5.4',
'5.5',
'5.6',
'7.0',
'7.1',
'7.2',
]
describe('Text PHP version', function() {
test(minorVersion, () => {
given('7').expect('7.0')
given('7.1').expect('7.1')
given('5.3.3').expect('5.3')
given('hhvm').expect('')
})
test(versionReduction, () => {
given(['5.3', '5.4', '5.5'], phpReleases).expect('5.3 - 5.5')
given(['5.4', '5.5', '5.6', '7.0', '7.1'], phpReleases).expect('5.4 - 7.1')
given(['5.5', '5.6', '7.0', '7.1', '7.2'], phpReleases).expect('>= 5.5')
given(['5.5', '5.6', '7.1', '7.2'], phpReleases).expect(
'5.5, 5.6, 7.1, 7.2'
)
given(['7.0', '7.1', '7.2'], phpReleases).expect('>= 7')
given(
['5.0', '5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2'],
phpReleases
).expect('>= 5')
given(['7.1', '7.2'], phpReleases).expect('>= 7.1')
given(['7.1'], phpReleases).expect('7.1')
given(['8.1'], phpReleases).expect('')
given([]).expect('')
})
})
describe('Composer version comparison', function() {
test(compare, () => {
// composer version scheme ordering
given('0.9.0', '1.0.0-alpha').expect(-1)
given('1.0.0-alpha', '1.0.0-alpha2').expect(-1)
given('1.0.0-alpha2', '1.0.0-beta').expect(-1)
given('1.0.0-beta', '1.0.0-beta2').expect(-1)
given('1.0.0-beta2', '1.0.0-RC').expect(-1)
given('1.0.0-RC', '1.0.0-RC2').expect(-1)
given('1.0.0-RC2', '1.0.0').expect(-1)
given('1.0.0', '1.0.0-patch').expect(-1)
given('1.0.0-patch', '1.0.0-dev').expect(-1)
given('1.0.0-dev', '1.0.1').expect(-1)
given('1.0.1', '1.0.x-dev').expect(-1)
// short versions should compare equal to long versions
given('1.0.0-p', '1.0.0-patch').expect(0)
given('1.0.0-a', '1.0.0-alpha').expect(0)
given('1.0.0-a2', '1.0.0-alpha2').expect(0)
given('1.0.0-b', '1.0.0-beta').expect(0)
given('1.0.0-b2', '1.0.0-beta2').expect(0)
// numeric suffixes
given('1.0.0-b1', '1.0.0-b2').expect(-1)
given('1.0.0-b10', '1.0.0-b11').expect(-1)
given('1.0.0-a1', '1.0.0-a2').expect(-1)
given('1.0.0-a10', '1.0.0-a11').expect(-1)
given('1.0.0-RC1', '1.0.0-RC2').expect(-1)
given('1.0.0-RC10', '1.0.0-RC11').expect(-1)
})
})