‪TYPO3CMS  11.5
FloatingPointTypesTest.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 
24 
29 {
35  public function ‪canParseFloatingPointTypesProvider(): array
36  {
37  return [
38  'FLOAT without precision' => [
39  'FLOAT',
40  FloatDataType::class,
41  -1,
42  -1,
43  ],
44  'FLOAT with precision' => [
45  'FLOAT(44)',
46  FloatDataType::class,
47  44,
48  -1,
49  ],
50  'FLOAT with precision and decimals' => [
51  'FLOAT(44,5)',
52  FloatDataType::class,
53  44,
54  5,
55  ],
56  'REAL without precision' => [
57  'REAL',
58  RealDataType::class,
59  -1,
60  -1,
61  ],
62  'REAL with precision' => [
63  'REAL(44)',
64  RealDataType::class,
65  44,
66  -1,
67  ],
68  'REAL with precision and decimals' => [
69  'REAL(44,5)',
70  RealDataType::class,
71  44,
72  5,
73  ],
74  'DOUBLE without precision' => [
75  'DOUBLE',
76  DoubleDataType::class,
77  -1,
78  -1,
79  ],
80  'DOUBLE with precision' => [
81  'DOUBLE(44)',
82  DoubleDataType::class,
83  44,
84  -1,
85  ],
86  'DOUBLE with precision and decimals' => [
87  'DOUBLE(44,5)',
88  DoubleDataType::class,
89  44,
90  5,
91  ],
92  ];
93  }
94 
103  public function ‪canParseDataType(
104  string $columnDefinition,
105  string $className,
106  int $precision = null,
107  int $scale = null
108  ): void {
109  $subject = $this->‪createSubject($columnDefinition);
110 
111  self::assertInstanceOf($className, $subject->dataType);
112  self::assertSame($precision, $subject->dataType->getPrecision());
113  self::assertSame($scale, $subject->dataType->getScale());
114  }
115 }
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\RealDataType
Definition: RealDataType.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\Tests\Unit\Database\Schema\Parser\DataTypes\FloatingPointTypesTest\canParseFloatingPointTypesProvider
‪array canParseFloatingPointTypesProvider()
Definition: FloatingPointTypesTest.php:35
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\FloatDataType
Definition: FloatDataType.php:24
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\DoubleDataType
Definition: DoubleDataType.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\FloatingPointTypesTest\canParseDataType
‪canParseDataType(string $columnDefinition, string $className, int $precision=null, int $scale=null)
Definition: FloatingPointTypesTest.php:103
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\AbstractDataTypeBaseTestCase
Definition: AbstractDataTypeBaseTestCase.php:29
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes
Definition: BinaryDataTypeTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\FloatingPointTypesTest
Definition: FloatingPointTypesTest.php:29