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