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