‪TYPO3CMS  9.5
SetTypeTest.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 ‪SetTypeTest extends UnitTestCase
29 {
33  protected function ‪setUp()
34  {
35  parent::setUp();
36  if (!Type::hasType(‪SetType::TYPE)) {
37  Type::addType(‪SetType::TYPE, SetType::class);
38  }
39  }
40 
45  {
46  $subject = Type::getType(‪SetType::TYPE);
47  $this->assertSame(‪SetType::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(‪SetType::TYPE);
67  $this->assertSame(
68  "SET('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
Definition: EnumTypeTest.php:4
‪TYPO3\CMS\Core\Database\Schema\Types\SetType
Definition: SetType.php:25
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\getSQLDeclaration
‪getSQLDeclaration()
Definition: SetTypeTest.php:53
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\setUp
‪setUp()
Definition: SetTypeTest.php:33
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest\getNameReturnsTypeIdentifier
‪getNameReturnsTypeIdentifier()
Definition: SetTypeTest.php:44
‪TYPO3\CMS\Core\Tests\Unit\Database\Schema\Types\SetTypeTest
Definition: SetTypeTest.php:29
‪TYPO3\CMS\Core\Database\Schema\Types\SetType\TYPE
‪const TYPE
Definition: SetType.php:26