‪TYPO3CMS  9.5
IntegerTypesTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
25 
30 {
36  public function ‪canParseIntegerDataTypeProvider(): array
37  {
38  return [
39  'TINYINT without length' => [
40  'TINYINT',
41  TinyIntDataType::class,
42  0,
43  ],
44  'SMALLINT without length' => [
45  'SMALLINT',
46  SmallIntDataType::class,
47  0,
48  ],
49  'MEDIUMINT without length' => [
50  'MEDIUMINT',
51  MediumIntDataType::class,
52  0,
53  ],
54  'INT without length' => [
55  'INT',
56  IntegerDataType::class,
57  0,
58  ],
59  'INTEGER without length' => [
60  'INTEGER',
61  IntegerDataType::class,
62  0,
63  ],
64  'BIGINT without length' => [
65  'BIGINT',
66  BigIntDataType::class,
67  0,
68  ],
69  // MySQL supports an extension for optionally specifying the display width of integer data types
70  // in parentheses following the base keyword for the type. For example, INT(4) specifies an INT
71  // with a display width of four digits.
72  // The display width does not constrain the range of values that can be stored in the column.
73  'TINYINT with length' => [
74  'TINYINT(4)',
75  TinyIntDataType::class,
76  4,
77  ],
78  'SMALLINT with length' => [
79  'SMALLINT(6)',
80  SmallIntDataType::class,
81  6,
82  ],
83  'MEDIUMINT with length' => [
84  'MEDIUMINT(8)',
85  MediumIntDataType::class,
86  8,
87  ],
88  'INT with length' => [
89  'INT(11)',
90  IntegerDataType::class,
91  11,
92  ],
93  'INTEGER with length' => [
94  'INTEGER(11)',
95  IntegerDataType::class,
96  11,
97  ],
98  'BIGINT with length' => [
99  'BIGINT(20)',
100  BigIntDataType::class,
101  20,
102  ],
103  ];
104  }
105 
113  public function ‪canParseDataType(string $columnDefinition, string $className, int $length)
114  {
115  $subject = $this->‪createSubject($columnDefinition);
116 
117  $this->assertInstanceOf($className, $subject->dataType);
118  $this->assertSame($length, $subject->dataType->getLength());
119  }
120 }
‪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:51
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\IntegerDataType
Definition: IntegerDataType.php:23
‪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:113
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\IntegerTypesTest\canParseIntegerDataTypeProvider
‪array canParseIntegerDataTypeProvider()
Definition: IntegerTypesTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\AbstractDataTypeBaseTestCase
Definition: AbstractDataTypeBaseTestCase.php:28
‪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:4
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\IntegerTypesTest
Definition: IntegerTypesTest.php:30