TYPO3 CMS  TYPO3_8-7
EnumTypeTest.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 
23 
27 class EnumTypeTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
32  protected function setUp()
33  {
34  parent::setUp();
35  if (!Type::hasType(EnumType::TYPE)) {
36  Type::addType(EnumType::TYPE, EnumType::class);
37  }
38  }
39 
43  public function getNameReturnsTypeIdentifier()
44  {
45  $subject = Type::getType(EnumType::TYPE);
46  $this->assertSame(EnumType::TYPE, $subject->getName());
47  }
48 
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(EnumType::TYPE);
66  $this->assertSame(
67  "ENUM('aValue', 'anotherValue')",
68  $subject->getSQLDeclaration($fieldDeclaration, $databaseProphet->reveal())
69  );
70  }
71 }