[TASK] Deprecate unused methods of VersionNumberUtility
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Utility / VersionNumberUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Utility;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\VersionNumberUtilityFixture;
18 use TYPO3\CMS\Core\Utility\VersionNumberUtility;
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20
21 /**
22 * Testcase for class \TYPO3\CMS\Core\Utility\VersionNumberUtility
23 */
24 class VersionNumberUtilityTest extends UnitTestCase
25 {
26
27 /**
28 * @return array
29 */
30 public function getNumericTypo3VersionNumberDataProvider()
31 {
32 return [
33 [
34 '6.0-dev',
35 '6.0.0'
36 ],
37 [
38 '4.5-alpha',
39 '4.5.0'
40 ],
41 [
42 '4.5-beta',
43 '4.5.0'
44 ],
45 [
46 '4.5-RC',
47 '4.5.0'
48 ],
49 [
50 '6.0.1',
51 '6.0.1'
52 ],
53 [
54 '6.2.0beta5',
55 '6.2.0'
56 ],
57 ];
58 }
59
60 /**
61 * Check whether getNumericTypo3Version handles all kinds of valid
62 * version strings
63 *
64 * @dataProvider getNumericTypo3VersionNumberDataProvider
65 * @test
66 * @param string $currentVersion
67 * @param string $expectedVersion
68 */
69 public function getNumericTypo3VersionNumber($currentVersion, $expectedVersion)
70 {
71 VersionNumberUtilityFixture::$versionNumber = $currentVersion;
72 $this->assertEquals($expectedVersion, VersionNumberUtilityFixture::getNumericTypo3Version());
73 }
74
75 /**
76 * Data provider for convertVersionsStringToVersionNumbersForcesVersionNumberInRange
77 *
78 * @return array
79 */
80 public function convertVersionsStringToVersionNumbersForcesVersionNumberInRangeDataProvider()
81 {
82 return [
83 'everything ok' => [
84 '4.2.0-4.4.99',
85 [
86 '4.2.0',
87 '4.4.99'
88 ]
89 ],
90 'too high value' => [
91 '4.2.0-4.4.2990',
92 [
93 '4.2.0',
94 '4.4.999'
95 ]
96 ],
97 'empty high value' => [
98 '4.2.0-0.0.0',
99 [
100 '4.2.0',
101 ''
102 ]
103 ]
104 ];
105 }
106
107 /**
108 * @test
109 * @dataProvider convertVersionsStringToVersionNumbersForcesVersionNumberInRangeDataProvider
110 */
111 public function convertVersionsStringToVersionNumbersForcesVersionNumberInRange($versionString, $expectedResult)
112 {
113 $versions = VersionNumberUtility::convertVersionsStringToVersionNumbers($versionString);
114 $this->assertEquals($expectedResult, $versions);
115 }
116 }