‪TYPO3CMS  ‪main
ExtensionXmlParserTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\DataProvider;
21 use PHPUnit\Framework\Attributes\Test;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 final class ‪ExtensionXmlParserTest extends UnitTestCase
26 {
27  #[DataProvider('isValidVersionNumberDataProvider')]
28  #[Test]
29  public function ‪isValidVersionNumber(string $versionNumber, bool $isValid): void
30  {
31  $subject = $this->getAccessibleMock(ExtensionXmlParser::class, null);
32  $subject->_set('version', $versionNumber);
33 
34  self::assertEquals($isValid, $subject->isValidVersionNumber());
35  }
36 
37  public static function ‪isValidVersionNumberDataProvider(): \Generator
38  {
39  yield 'Successive zeros are not allowed' => [
40  '00.2.3',
41  false,
42  ];
43  yield 'Version premodifiers are not allowed' => [
44  'v11.2.3',
45  false,
46  ];
47  yield 'Version postmodifiers are not allowed' => [
48  '11.2.3-pre-release',
49  false,
50  ];
51  yield 'Characters are not allowed in general' => [
52  '11.a.3',
53  false,
54  ];
55  yield 'More than three characters are not allowed' => [
56  '11.2.3999',
57  false,
58  ];
59  yield 'Version most use three segements (major, minor, patch)' => [
60  '11.2',
61  false,
62  ];
63  yield 'Successive separators are not allowed' => [
64  '11..2',
65  false,
66  ];
67  yield 'Leading separator is not allowed' => [
68  '.11.2',
69  false,
70  ];
71  yield 'Invalid separator' => [
72  '11-2-3',
73  false,
74  ];
75  yield 'Missing separator' => [
76  '1123',
77  false,
78  ];
79  yield 'Valid version number' => [
80  '11.2.3',
81  true,
82  ];
83  }
84 }
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Parser\ExtensionXmlParserTest\isValidVersionNumberDataProvider
‪static isValidVersionNumberDataProvider()
Definition: ExtensionXmlParserTest.php:37
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Parser\ExtensionXmlParserTest
Definition: ExtensionXmlParserTest.php:26
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Parser
Definition: ExtensionXmlParserTest.php:18
‪TYPO3\CMS\Extensionmanager\Tests\Unit\Parser\ExtensionXmlParserTest\isValidVersionNumber
‪isValidVersionNumber(string $versionNumber, bool $isValid)
Definition: ExtensionXmlParserTest.php:29
‪TYPO3\CMS\Extensionmanager\Parser\ExtensionXmlParser
Definition: ExtensionXmlParser.php:31