[BUGFIX] Add missing namespace parts
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / FormDataProvider / TcaTextTest.php
1 <?php
2 declare(strict_types=1);
3 namespace TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use TYPO3\CMS\Backend\Form\FormDataProvider\TcaText;
19 use TYPO3\CMS\Core\Configuration\Richtext;
20 use TYPO3\CMS\Core\Html\RteHtmlParser;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22
23 /**
24 * Test case
25 */
26 class TcaTextTest extends \TYPO3\Components\TestingFramework\Core\Unit\UnitTestCase
27 {
28 /**
29 * @test
30 */
31 public function addDataSetsRichtextConfigurationAndTransformsContent()
32 {
33 $input = [
34 'tableName' => 'aTable',
35 'effectivePid' => 42,
36 'recordTypeValue' => 23,
37 'databaseRow' => [
38 'aField' => 'notProcessedContent',
39 ],
40 'processedTca' => [
41 'columns' => [
42 'aField' => [
43 'config' => [
44 'type' => 'text',
45 'enableRichtext' => true,
46 ],
47 ],
48 ],
49 ],
50 ];
51 $expected = [
52 'tableName' => 'aTable',
53 'effectivePid' => 42,
54 'recordTypeValue' => 23,
55 'databaseRow' => [
56 'aField' => 'processedContent',
57 ],
58 'processedTca' => [
59 'columns' => [
60 'aField' => [
61 'config' => [
62 'type' => 'text',
63 'enableRichtext' => true,
64 'richtextConfiguration' => [
65 'aConfig' => 'option',
66 ],
67 ],
68 ],
69 ],
70 ],
71 ];
72
73 $richtextConfigurationProphecy = $this->prophesize(Richtext::class);
74 GeneralUtility::addInstance(Richtext::class, $richtextConfigurationProphecy->reveal());
75 $rteHtmlParserPropehy = $this->prophesize(RteHtmlParser::class);
76 GeneralUtility::addInstance(RteHtmlParser::class, $rteHtmlParserPropehy->reveal());
77
78 $richtextConfigurationProphecy
79 ->getConfiguration(
80 'aTable',
81 'aField',
82 42,
83 23,
84 [
85 'type' => 'text',
86 'enableRichtext' => true,
87 ]
88 )
89 ->willReturn([ 'aConfig' => 'option' ]);
90 $rteHtmlParserPropehy->init('aTable:aField', 42)->shouldBeCalled();
91 $rteHtmlParserPropehy
92 ->RTE_transform(
93 'notProcessedContent',
94 [],
95 'rte',
96 [ 'aConfig' => 'option']
97 )
98 ->willReturn('processedContent');
99
100 $this->assertSame($expected, (new TcaText())->addData($input));
101 }
102 }