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