‪TYPO3CMS  9.5
VersionNumberUtilityTest.php
Go to the documentation of this file.
1 <?php
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 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪VersionNumberUtilityTest extends UnitTestCase
25 {
32  {
33  return [
34  ['4003003', '4.3.3'],
35  ['4012003', '4.12.3'],
36  ['5000000', '5.0.0'],
37  ['5000001', '5.0.1'],
38  ['3008001', '3.8.1'],
39  ['1012', '0.1.12']
40  ];
41  }
42 
50  {
51  return [
52  'boolean' => [true],
53  'float' => [5.4],
54  'array' => [[]],
55  'string' => ['300ABCD'],
56  'object' => [new \stdClass()],
57  'NULL' => [null],
58  'function' => [function () {
59  }]
60  ];
61  }
62 
68  {
69  $this->assertEquals($expected, ‪VersionNumberUtility::convertVersionNumberToInteger($version));
70  }
71 
76  public function ‪convertIntegerToVersionNumberConvertsIntegerToVersionNumber($versionNumber, $expected)
77  {
78  // Make sure incoming value is an integer
79  $versionNumber = (int)$versionNumber;
80  $this->assertEquals($expected, ‪VersionNumberUtility::convertIntegerToVersionNumber($versionNumber));
81  }
82 
88  {
89  $this->expectException(\InvalidArgumentException::class);
90  $this->expectExceptionCode(1334072223);
92  }
93 
98  {
99  return [
100  [
101  '6.0-dev',
102  '6.0.0'
103  ],
104  [
105  '4.5-alpha',
106  '4.5.0'
107  ],
108  [
109  '4.5-beta',
110  '4.5.0'
111  ],
112  [
113  '4.5-RC',
114  '4.5.0'
115  ],
116  [
117  '6.0.1',
118  '6.0.1'
119  ],
120  [
121  '6.2.0beta5',
122  '6.2.0'
123  ],
124  ];
125  }
126 
136  public function ‪getNumericTypo3VersionNumber($currentVersion, $expectedVersion)
137  {
139  $this->assertEquals($expectedVersion, ‪VersionNumberUtilityFixture::getNumericTypo3Version());
140  }
141 
148  {
149  return [
150  'everything ok' => [
151  '4.2.0-4.4.99',
152  [
153  '4.2.0',
154  '4.4.99'
155  ]
156  ],
157  'too high value' => [
158  '4.2.0-4.4.2990',
159  [
160  '4.2.0',
161  '4.4.999'
162  ]
163  ],
164  'empty high value' => [
165  '4.2.0-0.0.0',
166  [
167  '4.2.0',
168  ''
169  ]
170  ]
171  ];
172  }
173 
178  public function ‪convertVersionsStringToVersionNumbersForcesVersionNumberInRange($versionString, $expectedResult)
179  {
181  $this->assertEquals($expectedResult, $versions);
182  }
183 }
‪TYPO3\CMS\Core\Utility\VersionNumberUtility
Definition: VersionNumberUtility.php:21
‪TYPO3\CMS\Core\Utility\VersionNumberUtility\getNumericTypo3Version
‪static string getNumericTypo3Version()
Definition: VersionNumberUtility.php:97
‪TYPO3\CMS\Core\Utility\VersionNumberUtility\convertIntegerToVersionNumber
‪static string convertIntegerToVersionNumber($versionInteger)
Definition: VersionNumberUtility.php:49
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\getNumericTypo3VersionNumberDataProvider
‪array getNumericTypo3VersionNumberDataProvider()
Definition: VersionNumberUtilityTest.php:97
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\validVersionNumberDataProvider
‪array validVersionNumberDataProvider()
Definition: VersionNumberUtilityTest.php:31
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest
Definition: VersionNumberUtilityTest.php:25
‪TYPO3\CMS\Core\Tests\Unit\Utility
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\convertIntegerToVersionNumberConvertsIntegerToVersionNumber
‪convertIntegerToVersionNumberConvertsIntegerToVersionNumber($versionNumber, $expected)
Definition: VersionNumberUtilityTest.php:76
‪TYPO3\CMS\Core\Utility\VersionNumberUtility\convertVersionNumberToInteger
‪static int convertVersionNumberToInteger($versionNumber)
Definition: VersionNumberUtility.php:28
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\convertVersionNumberToIntegerConvertsVersionNumbersToIntegers
‪convertVersionNumberToIntegerConvertsVersionNumbersToIntegers($expected, $version)
Definition: VersionNumberUtilityTest.php:67
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\convertVersionsStringToVersionNumbersForcesVersionNumberInRange
‪convertVersionsStringToVersionNumbersForcesVersionNumberInRange($versionString, $expectedResult)
Definition: VersionNumberUtilityTest.php:178
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\VersionNumberUtilityFixture\$versionNumber
‪static $versionNumber
Definition: VersionNumberUtilityFixture.php:23
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\getNumericTypo3VersionNumber
‪getNumericTypo3VersionNumber($currentVersion, $expectedVersion)
Definition: VersionNumberUtilityTest.php:136
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\invalidVersionNumberDataProvider
‪array invalidVersionNumberDataProvider()
Definition: VersionNumberUtilityTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\convertVersionsStringToVersionNumbersForcesVersionNumberInRangeDataProvider
‪array convertVersionsStringToVersionNumbersForcesVersionNumberInRangeDataProvider()
Definition: VersionNumberUtilityTest.php:147
‪TYPO3\CMS\Core\Utility\VersionNumberUtility\convertVersionsStringToVersionNumbers
‪static array convertVersionsStringToVersionNumbers($versionsString)
Definition: VersionNumberUtility.php:127
‪TYPO3\CMS\Core\Tests\Unit\Utility\VersionNumberUtilityTest\convertIntegerToVersionNumberConvertsOtherTypesAsIntegerToVersionNumber
‪convertIntegerToVersionNumberConvertsOtherTypesAsIntegerToVersionNumber($version)
Definition: VersionNumberUtilityTest.php:87
‪TYPO3\CMS\Core\Tests\Unit\Utility\Fixtures\VersionNumberUtilityFixture
Definition: VersionNumberUtilityFixture.php:22