‪TYPO3CMS  10.4
EnumTypeTest.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 
20 use Doctrine\DBAL\Platforms\AbstractPlatform;
21 use Doctrine\DBAL\Types\Type;
22 use Prophecy\Argument;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪EnumTypeTest extends UnitTestCase
30 {
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  if (!Type::hasType(‪EnumType::TYPE)) {
38  Type::addType(‪EnumType::TYPE, EnumType::class);
39  }
40  }
41 
46  {
47  $subject = Type::getType(‪EnumType::TYPE);
48  self::assertSame(‪EnumType::TYPE, $subject->getName());
49  }
50 
54  public function ‪getSQLDeclaration()
55  {
56  $fieldDeclaration = [
57  'unquotedValues' => ['aValue', 'anotherValue'],
58  ];
59 
60  $databaseProphet = $this->prophesize(AbstractPlatform::class);
61  $databaseProphet->quoteStringLiteral(Argument::cetera())->will(
62  function (‪$args) {
63  return "'" . ‪$args[0] . "'";
64  }
65  );
66 
67  $subject = Type::getType(‪EnumType::TYPE);
68  self::assertSame(
69  "ENUM('aValue', 'anotherValue')",
70  $subject->getSQLDeclaration($fieldDeclaration, $databaseProphet->reveal())
71  );
72  }
73 }
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\EnumTypeTest\setUp
‪setUp()
Definition: EnumTypeTest.php:34
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types
Definition: EnumTypeTest.php:18
‪TYPO3\CMS\Core\Database\Schema\Types\EnumType
Definition: EnumType.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\EnumTypeTest
Definition: EnumTypeTest.php:30
‪TYPO3\CMS\Core\Database\Schema\Types\EnumType\TYPE
‪const TYPE
Definition: EnumType.php:28
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\EnumTypeTest\getNameReturnsTypeIdentifier
‪getNameReturnsTypeIdentifier()
Definition: EnumTypeTest.php:45
‪$args
‪$args
Definition: validateRstFiles.php:214
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\EnumTypeTest\getSQLDeclaration
‪getSQLDeclaration()
Definition: EnumTypeTest.php:54