‪TYPO3CMS  11.5
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;
23 use Prophecy\PhpUnit\ProphecyTrait;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪SetTypeTest extends UnitTestCase
31 {
32  use ProphecyTrait;
33 
37  protected function ‪setUp(): void
38  {
39  parent::setUp();
40  if (!Type::hasType(‪SetType::TYPE)) {
41  Type::addType(‪SetType::TYPE, SetType::class);
42  }
43  }
44 
48  public function ‪getNameReturnsTypeIdentifier(): void
49  {
50  $subject = Type::getType(‪SetType::TYPE);
51  self::assertSame(‪SetType::TYPE, $subject->getName());
52  }
53 
57  public function ‪getSQLDeclaration(): void
58  {
59  $fieldDeclaration = [
60  'unquotedValues' => ['aValue', 'anotherValue'],
61  ];
62 
63  $databaseProphet = $this->prophesize(AbstractPlatform::class);
64  $databaseProphet->quoteStringLiteral(Argument::cetera())->will(
65  static function (‪$args) {
66  return "'" . ‪$args[0] . "'";
67  }
68  );
69 
70  $subject = Type::getType(‪SetType::TYPE);
71  self::assertSame(
72  "SET('aValue', 'anotherValue')",
73  $subject->getSQLDeclaration($fieldDeclaration, $databaseProphet->reveal())
74  );
75  }
76 }
‪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:56
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\setUp
‪setUp()
Definition: SetTypeTest.php:36
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\getNameReturnsTypeIdentifier
‪getNameReturnsTypeIdentifier()
Definition: SetTypeTest.php:47
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest
Definition: SetTypeTest.php:31
‪$args
‪$args
Definition: validateRstFiles.php:214
‪TYPO3\CMS\Core\Database\Schema\Types\SetType\TYPE
‪const TYPE
Definition: SetType.php:28