diff options
Diffstat (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php')
-rw-r--r-- | vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php new file mode 100644 index 00000000..60cec6c0 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/Util/VersionTest.php | |||
@@ -0,0 +1,87 @@ | |||
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 | |||
12 | namespace Symfony\Component\Intl\Tests\Util; | ||
13 | |||
14 | use Symfony\Component\Intl\Util\Version; | ||
15 | |||
16 | /** | ||
17 | * @author Bernhard Schussek <bschussek@gmail.com> | ||
18 | */ | ||
19 | class VersionTest extends \PHPUnit_Framework_TestCase | ||
20 | { | ||
21 | public function normalizeProvider() | ||
22 | { | ||
23 | return array( | ||
24 | array(null, '1', '1'), | ||
25 | array(null, '1.2', '1.2'), | ||
26 | array(null, '1.2.3', '1.2.3'), | ||
27 | array(null, '1.2.3.4', '1.2.3.4'), | ||
28 | array(1, '1', '1'), | ||
29 | array(1, '1.2', '1'), | ||
30 | array(1, '1.2.3', '1'), | ||
31 | array(1, '1.2.3.4', '1'), | ||
32 | array(2, '1', '1'), | ||
33 | array(2, '1.2', '1.2'), | ||
34 | array(2, '1.2.3', '1.2'), | ||
35 | array(2, '1.2.3.4', '1.2'), | ||
36 | array(3, '1', '1'), | ||
37 | array(3, '1.2', '1.2'), | ||
38 | array(3, '1.2.3', '1.2.3'), | ||
39 | array(3, '1.2.3.4', '1.2.3'), | ||
40 | array(4, '1', '1'), | ||
41 | array(4, '1.2', '1.2'), | ||
42 | array(4, '1.2.3', '1.2.3'), | ||
43 | array(4, '1.2.3.4', '1.2.3.4'), | ||
44 | ); | ||
45 | } | ||
46 | |||
47 | /** | ||
48 | * @dataProvider normalizeProvider | ||
49 | */ | ||
50 | public function testNormalize($precision, $version, $result) | ||
51 | { | ||
52 | $this->assertSame($result, Version::normalize($version, $precision)); | ||
53 | } | ||
54 | |||
55 | public function compareProvider() | ||
56 | { | ||
57 | return array( | ||
58 | array(null, '1', '==', '1', true), | ||
59 | array(null, '1.0', '==', '1.1', false), | ||
60 | array(null, '1.0.0', '==', '1.0.1', false), | ||
61 | array(null, '1.0.0.0', '==', '1.0.0.1', false), | ||
62 | |||
63 | array(1, '1', '==', '1', true), | ||
64 | array(1, '1.0', '==', '1.1', true), | ||
65 | array(1, '1.0.0', '==', '1.0.1', true), | ||
66 | array(1, '1.0.0.0', '==', '1.0.0.1', true), | ||
67 | |||
68 | array(2, '1', '==', '1', true), | ||
69 | array(2, '1.0', '==', '1.1', false), | ||
70 | array(2, '1.0.0', '==', '1.0.1', true), | ||
71 | array(2, '1.0.0.0', '==', '1.0.0.1', true), | ||
72 | |||
73 | array(3, '1', '==', '1', true), | ||
74 | array(3, '1.0', '==', '1.1', false), | ||
75 | array(3, '1.0.0', '==', '1.0.1', false), | ||
76 | array(3, '1.0.0.0', '==', '1.0.0.1', true), | ||
77 | ); | ||
78 | } | ||
79 | |||
80 | /** | ||
81 | * @dataProvider compareProvider | ||
82 | */ | ||
83 | public function testCompare($precision, $version1, $operator, $version2, $result) | ||
84 | { | ||
85 | $this->assertSame($result, Version::compare($version1, $version2, $operator, $precision)); | ||
86 | } | ||
87 | } | ||