‪TYPO3CMS  10.4
BinaryDataTypeTest.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  'BINARY without length' => [
40  'BINARY',
41  BinaryDataType::class,
42  0,
43  ],
44  'BINARY with length' => [
45  'BINARY(200)',
46  BinaryDataType::class,
47  200,
48  ],
49  'VARBINARY with length' => [
50  'VARBINARY(200)',
51  VarBinaryDataType::class,
52  200,
53  ],
54  ];
55  }
56 
64  public function ‪canParseDataType(string $columnDefinition, string $className, int $length)
65  {
66  $subject = $this->‪createSubject($columnDefinition);
67 
68  self::assertInstanceOf($className, $subject->dataType);
69  self::assertSame($length, $subject->dataType->getLength());
70  }
71 
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` VARBINARY);'))->parse();
81  }
82 }
‪TYPO3\CMS\Core\Database\Schema\Exception\StatementException
Definition: StatementException.php:24
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\VarBinaryDataType
Definition: VarBinaryDataType.php:24
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\BinaryDataTypeTest\lengthIsRequiredForVarBinaryType
‪lengthIsRequiredForVarBinaryType()
Definition: BinaryDataTypeTest.php:75
‪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\Tests\Unit\Database\Schema\Parser\DataTypes\BinaryDataTypeTest\canParseBinaryDataTypeProvider
‪array canParseBinaryDataTypeProvider()
Definition: BinaryDataTypeTest.php:36
‪TYPO3\CMS\Core\Database\Schema\Parser\AST\DataType\BinaryDataType
Definition: BinaryDataType.php:24
‪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\BinaryDataTypeTest
Definition: BinaryDataTypeTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Parser\DataTypes\BinaryDataTypeTest\canParseDataType
‪canParseDataType(string $columnDefinition, string $className, int $length)
Definition: BinaryDataTypeTest.php:64