TYPO3 CMS  TYPO3_8-7
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 
26 class TcaTextTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
27 {
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  'richtextConfigurationName' => '',
65  'richtextConfiguration' => [
66  'aConfig' => 'option',
67  ],
68  ],
69  ],
70  ],
71  ],
72  ];
73 
74  $richtextConfigurationProphecy = $this->prophesize(Richtext::class);
75  GeneralUtility::addInstance(Richtext::class, $richtextConfigurationProphecy->reveal());
76  $rteHtmlParserPropehy = $this->prophesize(RteHtmlParser::class);
77  GeneralUtility::addInstance(RteHtmlParser::class, $rteHtmlParserPropehy->reveal());
78 
79  $richtextConfigurationProphecy
80  ->getConfiguration(
81  'aTable',
82  'aField',
83  42,
84  23,
85  [
86  'type' => 'text',
87  'enableRichtext' => true,
88  ]
89  )
90  ->willReturn([ 'aConfig' => 'option' ]);
91  $rteHtmlParserPropehy->init('aTable:aField', 42)->shouldBeCalled();
92  $rteHtmlParserPropehy
93  ->RTE_transform(
94  'notProcessedContent',
95  [],
96  'rte',
97  [ 'aConfig' => 'option']
98  )
99  ->willReturn('processedContent');
100 
101  $this->assertSame($expected, (new TcaText())->addData($input));
102  }
103 }
static addInstance($className, $instance)