dffee9888ad4b4977730e4fc393badcd9626811b
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Database / Schema / Types / SetTypeTest.php
1 <?php
2 declare(strict_types=1);
3
4 namespace TYPO3\CMS\Core\Tests\Unit\Database;
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;
22 use TYPO3\CMS\Core\Database\Schema\Types\SetType;
23
24 /**
25 * Tests for SetType
26 */
27 class SetTypeTest extends \TYPO3\Components\TestingFramework\Core\UnitTestCase
28 {
29 /**
30 * Set up the test subject
31 */
32 protected function setUp()
33 {
34 parent::setUp();
35 if (!Type::hasType(SetType::TYPE)) {
36 Type::addType(SetType::TYPE, SetType::class);
37 }
38 }
39
40 /**
41 * @test
42 */
43 public function getNameReturnsTypeIdentifier()
44 {
45 $subject = Type::getType(SetType::TYPE);
46 $this->assertSame(SetType::TYPE, $subject->getName());
47 }
48
49 /**
50 * @test
51 */
52 public function getSQLDeclaration()
53 {
54 $fieldDeclaration = [
55 'unquotedValues' => ['aValue', 'anotherValue'],
56 ];
57
58 $databaseProphet = $this->prophesize(AbstractPlatform::class);
59 $databaseProphet->quoteStringLiteral(Argument::cetera())->will(
60 function ($args) {
61 return "'" . $args[0] . "'";
62 }
63 );
64
65 $subject = Type::getType(SetType::TYPE);
66 $this->assertSame(
67 "SET('aValue', 'anotherValue')",
68 $subject->getSQLDeclaration($fieldDeclaration, $databaseProphet->reveal())
69 );
70 }
71 }