‪TYPO3CMS  10.4
SetTypeTest.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 ‪SetTypeTest extends UnitTestCase
30 {
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  if (!Type::hasType(‪SetType::TYPE)) {
38  Type::addType(‪SetType::TYPE, SetType::class);
39  }
40  }
41 
46  {
47  $subject = Type::getType(‪SetType::TYPE);
48  self::assertSame(‪SetType::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(‪SetType::TYPE);
68  self::assertSame(
69  "SET('aValue', 'anotherValue')",
70  $subject->getSQLDeclaration($fieldDeclaration, $databaseProphet->reveal())
71  );
72  }
73 }
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types
Definition: EnumTypeTest.php:18
‪TYPO3\CMS\Core\Database\Schema\Types\SetType
Definition: SetType.php:27
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\getSQLDeclaration
‪getSQLDeclaration()
Definition: SetTypeTest.php:54
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\setUp
‪setUp()
Definition: SetTypeTest.php:34
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\getNameReturnsTypeIdentifier
‪getNameReturnsTypeIdentifier()
Definition: SetTypeTest.php:45
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest
Definition: SetTypeTest.php:30
‪$args
‪$args
Definition: validateRstFiles.php:214
‪TYPO3\CMS\Core\Database\Schema\Types\SetType\TYPE
‪const TYPE
Definition: SetType.php:28