‪TYPO3CMS  9.5
FixedPointTypesTest.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 
22 
27 {
33  public function ‪canParseFixedPointTypesProvider(): array
34  {
35  return [
36  'DECIMAL without precision and scale' => [
37  'DECIMAL',
38  DecimalDataType::class,
39  -1,
40  -1,
41  ],
42  'DECIMAL with precision' => [
43  'DECIMAL(5)',
44  DecimalDataType::class,
45  5,
46  -1,
47  ],
48  'DECIMAL with precision and scale' => [
49  'DECIMAL(5,2)',
50  DecimalDataType::class,
51  5,
52  2,
53  ],
54  'NUMERIC without length' => [
55  'NUMERIC',
56  NumericDataType::class,
57  -1,
58  -1,
59  ],
60  'NUMERIC with length' => [
61  'NUMERIC(5)',
62  NumericDataType::class,
63  5,
64  -1,
65  ],
66  'NUMERIC with length and precision' => [
67  'NUMERIC(5,2)',
68  NumericDataType::class,
69  5,
70  2,
71  ],
72  ];
73  }
74 
83  public function ‪canParseDataType(
84  string $columnDefinition,
85  string $className,
86  int $precision = null,
87  int $scale = null
88  ) {
89  $subject = $this->‪createSubject($columnDefinition);
90 
91  $this->assertInstanceOf($className, $subject->dataType);
92  $this->assertSame($precision, $subject->dataType->getPrecision());
93  $this->assertSame($scale, $subject->dataType->getScale());
94  }
95 }
‪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\FixedPointTypesTest
Definition: FixedPointTypesTest.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\FixedPointTypesTest\canParseFixedPointTypesProvider
‪array canParseFixedPointTypesProvider()
Definition: FixedPointTypesTest.php:33
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\DecimalDataType
Definition: DecimalDataType.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\FixedPointTypesTest\canParseDataType
‪canParseDataType(string $columnDefinition, string $className, int $precision=null, int $scale=null)
Definition: FixedPointTypesTest.php:83
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\AbstractDataTypeBaseTestCase
Definition: AbstractDataTypeBaseTestCase.php:28
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\NumericDataType
Definition: NumericDataType.php:23
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes
Definition: BinaryDataTypeTest.php:4