[FEATURE] Doctrine: Implement SchemaMigrationService
[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 use TYPO3\CMS\Core\Tests\UnitTestCase;
24
25 /**
26 * Tests for SetType
27 */
28 class SetTypeTest extends UnitTestCase
29 {
30 /**
31 * Set up the test subject
32 */
33 protected function setUp()
34 {
35 parent::setUp();
36 if (!Type::hasType(SetType::TYPE)) {
37 Type::addType(SetType::TYPE, SetType::class);
38 }
39 }
40
41 /**
42 * @test
43 */
44 public function getNameReturnsTypeIdentifier()
45 {
46 $subject = Type::getType(SetType::TYPE);
47 $this->assertSame(SetType::TYPE, $subject->getName());
48 }
49
50 /**
51 * @test
52 */
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 }