‪TYPO3CMS  11.5
IntegerTypesTest.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 
26 
31 {
37  public function ‪canParseIntegerDataTypeProvider(): array
38  {
39  return [
40  'TINYINT without length' => [
41  'TINYINT',
42  TinyIntDataType::class,
43  0,
44  ],
45  'SMALLINT without length' => [
46  'SMALLINT',
47  SmallIntDataType::class,
48  0,
49  ],
50  'MEDIUMINT without length' => [
51  'MEDIUMINT',
52  MediumIntDataType::class,
53  0,
54  ],
55  'INT without length' => [
56  'INT',
57  IntegerDataType::class,
58  0,
59  ],
60  'INTEGER without length' => [
61  'INTEGER',
62  IntegerDataType::class,
63  0,
64  ],
65  'BIGINT without length' => [
66  'BIGINT',
67  BigIntDataType::class,
68  0,
69  ],
70  // MySQL supports an extension for optionally specifying the display width of integer data types
71  // in parentheses following the base keyword for the type. For example, INT(4) specifies an INT
72  // with a display width of four digits.
73  // The display width does not constrain the range of values that can be stored in the column.
74  'TINYINT with length' => [
75  'TINYINT(4)',
76  TinyIntDataType::class,
77  4,
78  ],
79  'SMALLINT with length' => [
80  'SMALLINT(6)',
81  SmallIntDataType::class,
82  6,
83  ],
84  'MEDIUMINT with length' => [
85  'MEDIUMINT(8)',
86  MediumIntDataType::class,
87  8,
88  ],
89  'INT with length' => [
90  'INT(11)',
91  IntegerDataType::class,
92  11,
93  ],
94  'INTEGER with length' => [
95  'INTEGER(11)',
96  IntegerDataType::class,
97  11,
98  ],
99  'BIGINT with length' => [
100  'BIGINT(20)',
101  BigIntDataType::class,
102  20,
103  ],
104  ];
105  }
106 
114  public function ‪canParseDataType(string $columnDefinition, string $className, int $length): void
115  {
116  $subject = $this->‪createSubject($columnDefinition);
117 
118  self::assertInstanceOf($className, $subject->dataType);
119  self::assertSame($length, $subject->dataType->getLength());
120  }
121 }
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\BigIntDataType
Definition: BigIntDataType.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\AbstractDataTypeBaseTestCase\createSubject
‪TYPO3 CMS Core Database Schema Parser AST CreateColumnDefinitionItem createSubject(string $statement)
Definition: AbstractDataTypeBaseTestCase.php:52
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\IntegerDataType
Definition: IntegerDataType.php:24
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\MediumIntDataType
Definition: MediumIntDataType.php:23
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\TinyIntDataType
Definition: TinyIntDataType.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\IntegerTypesTest\canParseDataType
‪canParseDataType(string $columnDefinition, string $className, int $length)
Definition: IntegerTypesTest.php:114
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\IntegerTypesTest\canParseIntegerDataTypeProvider
‪array canParseIntegerDataTypeProvider()
Definition: IntegerTypesTest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\AbstractDataTypeBaseTestCase
Definition: AbstractDataTypeBaseTestCase.php:29
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\SmallIntDataType
Definition: SmallIntDataType.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes
Definition: BinaryDataTypeTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\IntegerTypesTest
Definition: IntegerTypesTest.php:31