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