aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php')
-rw-r--r--vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php111
1 files changed, 111 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php
new file mode 100644
index 00000000..d1a7e8c1
--- /dev/null
+++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/IcuVersionTest.php
@@ -0,0 +1,111 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Intl\Tests\Util;
13
14use Symfony\Component\Intl\Util\IcuVersion;
15
16/**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19class IcuVersionTest extends \PHPUnit_Framework_TestCase
20{
21 public function normalizeProvider()
22 {
23 return array(
24 array(null, '1', '10'),
25 array(null, '1.2', '12'),
26 array(null, '1.2.3', '12.3'),
27 array(null, '1.2.3.4', '12.3.4'),
28 array(1, '1', '10'),
29 array(1, '1.2', '12'),
30 array(1, '1.2.3', '12'),
31 array(1, '1.2.3.4', '12'),
32 array(2, '1', '10'),
33 array(2, '1.2', '12'),
34 array(2, '1.2.3', '12.3'),
35 array(2, '1.2.3.4', '12.3'),
36 array(3, '1', '10'),
37 array(3, '1.2', '12'),
38 array(3, '1.2.3', '12.3'),
39 array(3, '1.2.3.4', '12.3.4'),
40 );
41 }
42
43 /**
44 * @dataProvider normalizeProvider
45 */
46 public function testNormalize($precision, $version, $result)
47 {
48 $this->assertSame($result, IcuVersion::normalize($version, $precision));
49 }
50
51 public function compareProvider()
52 {
53 return array(
54 array(null, '1', '==', '1', true),
55 array(null, '1.0', '==', '1.1', false),
56 array(null, '1.0.0', '==', '1.0.1', false),
57 array(null, '1.0.0.0', '==', '1.0.0.1', false),
58 array(null, '1.0.0.0.0', '==', '1.0.0.0.1', false),
59
60 array(null, '1', '==', '10', true),
61 array(null, '1.0', '==', '11', false),
62 array(null, '1.0.0', '==', '10.1', false),
63 array(null, '1.0.0.0', '==', '10.0.1', false),
64 array(null, '1.0.0.0.0', '==', '10.0.0.1', false),
65
66 array(1, '1', '==', '1', true),
67 array(1, '1.0', '==', '1.1', false),
68 array(1, '1.0.0', '==', '1.0.1', true),
69 array(1, '1.0.0.0', '==', '1.0.0.1', true),
70 array(1, '1.0.0.0.0', '==', '1.0.0.0.1', true),
71
72 array(1, '1', '==', '10', true),
73 array(1, '1.0', '==', '11', false),
74 array(1, '1.0.0', '==', '10.1', true),
75 array(1, '1.0.0.0', '==', '10.0.1', true),
76 array(1, '1.0.0.0.0', '==', '10.0.0.1', true),
77
78 array(2, '1', '==', '1', true),
79 array(2, '1.0', '==', '1.1', false),
80 array(2, '1.0.0', '==', '1.0.1', false),
81 array(2, '1.0.0.0', '==', '1.0.0.1', true),
82 array(2, '1.0.0.0.0', '==', '1.0.0.0.1', true),
83
84 array(2, '1', '==', '10', true),
85 array(2, '1.0', '==', '11', false),
86 array(2, '1.0.0', '==', '10.1', false),
87 array(2, '1.0.0.0', '==', '10.0.1', true),
88 array(2, '1.0.0.0.0', '==', '10.0.0.1', true),
89
90 array(3, '1', '==', '1', true),
91 array(3, '1.0', '==', '1.1', false),
92 array(3, '1.0.0', '==', '1.0.1', false),
93 array(3, '1.0.0.0', '==', '1.0.0.1', false),
94 array(3, '1.0.0.0.0', '==', '1.0.0.0.1', true),
95
96 array(3, '1', '==', '10', true),
97 array(3, '1.0', '==', '11', false),
98 array(3, '1.0.0', '==', '10.1', false),
99 array(3, '1.0.0.0', '==', '10.0.1', false),
100 array(3, '1.0.0.0.0', '==', '10.0.0.1', true),
101 );
102 }
103
104 /**
105 * @dataProvider compareProvider
106 */
107 public function testCompare($precision, $version1, $operator, $version2, $result)
108 {
109 $this->assertSame($result, IcuVersion::compare($version1, $version2, $operator, $precision));
110 }
111}