‪TYPO3CMS  9.5
TcaTextTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
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 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪TcaTextTest extends UnitTestCase
28 {
33  {
34  $input = [
35  'tableName' => 'aTable',
36  'effectivePid' => 42,
37  'recordTypeValue' => 23,
38  'databaseRow' => [
39  'aField' => 'notProcessedContent',
40  ],
41  'processedTca' => [
42  'columns' => [
43  'aField' => [
44  'config' => [
45  'type' => 'text',
46  'enableRichtext' => true,
47  ],
48  ],
49  ],
50  ],
51  ];
52  $expected = [
53  'tableName' => 'aTable',
54  'effectivePid' => 42,
55  'recordTypeValue' => 23,
56  'databaseRow' => [
57  'aField' => 'processedContent',
58  ],
59  'processedTca' => [
60  'columns' => [
61  'aField' => [
62  'config' => [
63  'type' => 'text',
64  'enableRichtext' => true,
65  'richtextConfigurationName' => '',
66  'richtextConfiguration' => [
67  'aConfig' => 'option',
68  ],
69  ],
70  ],
71  ],
72  ],
73  ];
74 
75  $richtextConfigurationProphecy = $this->prophesize(Richtext::class);
76  GeneralUtility::addInstance(Richtext::class, $richtextConfigurationProphecy->reveal());
77  $rteHtmlParserPropehy = $this->prophesize(RteHtmlParser::class);
78  GeneralUtility::addInstance(RteHtmlParser::class, $rteHtmlParserPropehy->reveal());
79 
80  $richtextConfigurationProphecy
81  ->getConfiguration(
82  'aTable',
83  'aField',
84  42,
85  23,
86  [
87  'type' => 'text',
88  'enableRichtext' => true,
89  ]
90  )
91  ->willReturn([ 'aConfig' => 'option' ]);
92  $rteHtmlParserPropehy->init('aTable:aField', 42)->shouldBeCalled();
93  $rteHtmlParserPropehy
94  ->RTE_transform(
95  'notProcessedContent',
96  [],
97  'rte',
98  [ 'aConfig' => 'option']
99  )
100  ->willReturn('processedContent');
101 
102  $this->assertSame($expected, (new ‪TcaText())->addData($input));
103  }
104 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTextTest\addDataSetsRichtextConfigurationAndTransformsContent
‪addDataSetsRichtextConfigurationAndTransformsContent()
Definition: TcaTextTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaTextTest
Definition: TcaTextTest.php:28
‪TYPO3\CMS\Core\Html\RteHtmlParser
Definition: RteHtmlParser.php:40
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaText
Definition: TcaText.php:28
‪TYPO3\CMS\Core\Configuration\Richtext
Definition: Richtext.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:3