[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / Utility / FormEngineUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
18
19 /**
20 * Test case
21 */
22 class FormEngineUtilityTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
23 {
24 /**
25 * @test
26 */
27 public function databaseRowCompatibilityKeepsSimpleValue()
28 {
29 $input = [
30 'uid' => 42,
31 'title' => 'aTitle',
32 ];
33 $expected = $input;
34 $this->assertEquals($expected, FormEngineUtility::databaseRowCompatibility($input));
35 }
36
37 /**
38 * @test
39 */
40 public function databaseRowCompatibilityImplodesSimpleArray()
41 {
42 $input = [
43 'uid' => 42,
44 'simpleArray' => [
45 0 => 1,
46 1 => 2,
47 ],
48 ];
49 $expected = $input;
50 $expected['simpleArray'] = '1,2';
51 $this->assertEquals($expected, FormEngineUtility::databaseRowCompatibility($input));
52 }
53
54 /**
55 * @test
56 */
57 public function databaseRowCompatibilityImplodesSelectArrayWithValuesAtSecondPosition()
58 {
59 $input = [
60 'uid' => 42,
61 'simpleArray' => [
62 0 => [
63 0 => 'aLabel',
64 1 => 'aValue',
65 ],
66 1 => [
67 0 => 'anotherLabel',
68 1 => 'anotherValue',
69 ],
70 ],
71 ];
72 $expected = $input;
73 $expected['simpleArray'] = 'aValue,anotherValue';
74 $this->assertEquals($expected, FormEngineUtility::databaseRowCompatibility($input));
75 }
76 }