‪TYPO3CMS  11.5
CharDataTypeTest.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 
25 
30 {
36  public function ‪canParseBinaryDataTypeProvider(): array
37  {
38  return [
39  'CHAR without length' => [
40  'CHAR',
41  CharDataType::class,
42  0,
43  ],
44  'CHAR with length' => [
45  'CHAR(200)',
46  CharDataType::class,
47  200,
48  ],
49  'VARCHAR with length' => [
50  'VARCHAR(200)',
51  VarCharDataType::class,
52  200,
53  ],
54  ];
55  }
56 
64  public function ‪canParseDataType(string $columnDefinition, string $className, int $length): void
65  {
66  $subject = $this->‪createSubject($columnDefinition);
67 
68  self::assertInstanceOf($className, $subject->dataType);
69  self::assertSame($length, $subject->dataType->getLength());
70  }
71 
75  public function ‪lengthIsRequiredForVarCharType(): void
76  {
77  $this->expectException(StatementException::class);
78  $this->expectExceptionCode(1471504822);
79  $this->expectExceptionMessage('The current data type requires a field length definition');
80  (new ‪Parser('CREATE TABLE `aTable`(`aField` VARCHAR);'))->parse();
81  }
82 }
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\VarCharDataType
Definition: VarCharDataType.php:24
‪TYPO3\CMS\Core\Database\Schema\Exception\StatementException
Definition: StatementException.php:24
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\CharDataTypeTest
Definition: CharDataTypeTest.php:30
‪TYPO3\CMS\Core\Database\Schema\Parser\Parser
Definition: Parser.php:71
‪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\Database\Schema\Parser\AST\DataType\CharDataType
Definition: CharDataType.php:24
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\CharDataTypeTest\canParseBinaryDataTypeProvider
‪array canParseBinaryDataTypeProvider()
Definition: CharDataTypeTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\CharDataTypeTest\lengthIsRequiredForVarCharType
‪lengthIsRequiredForVarCharType()
Definition: CharDataTypeTest.php:75
‪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\CharDataTypeTest\canParseDataType
‪canParseDataType(string $columnDefinition, string $className, int $length)
Definition: CharDataTypeTest.php:64