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