‪TYPO3CMS  11.5
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
22 
24 {
25  protected const ‪VALUE_ContentId = 100;
26 
28  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
29  ];
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34  $this->importCSVDataSet(__DIR__ . '/DataSet/LiveDefaultPages.csv');
35  $this->importCSVDataSet(__DIR__ . '/DataSet/LiveDefaultElements.csv');
36  }
37 
42  {
43  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '<?xml version="1.0" encoding="UTF-8"?>
44 <T3DataStructure>
45  <meta>
46  <langDisable>0</langDisable>
47  </meta>
48  <ROOT type="array">
49  <type>array</type>
50  <el type="array">
51  <settings.bodytext>
52  <TCEforms type="array">
53  <label>Random Bodytext</label>
54  <config type="array">
55  <type>text</type>
56  <cols>48</cols>
57  <rows>5</rows>
58  <enableRichtext>1</enableRichtext>
59  <richtextConfiguration>default</richtextConfiguration>
60  </config>
61  </TCEforms>
62  </settings.bodytext>
63  </el>
64  </ROOT>
65 </T3DataStructure>';
66 
67  $expected = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
68 <T3FlexForms>
69  <data>
70  <sheet index="sDEF">
71  <language index="lDEF">
72  <field index="settings.isNotDefined">1</field>
73  <field index="settings.bodytext">
74  <value index="vDEF">&lt;p class=&quot;align-right&quot;&gt;First line&lt;/p&gt;
75 &lt;p&gt;Last line&lt;/p&gt;</value>
76  </field>
77  </language>
78  </sheet>
79  </data>
80 </T3FlexForms>';
81 
82  $this->actionService->modifyRecords(1, [
83  'tt_content' => [
84  'uid' => self::VALUE_ContentId,
85  'pi_flexform' => [
86  'data' => [
87  'sDEF' => [
88  'lDEF' => [
89  'settings.isNotDefined' => '1',
90  'settings.bodytext' => [
91  'vDEF' => '<p class="align-right">First line</p>
92 
93 <p>Last line</p>',
94  ],
95  ],
96  ],
97  ],
98  ],
99  ],
100  ]);
101 
102  $queryBuilder = $this->getConnectionPool()
103  ->getQueryBuilderForTable('tt_content');
104  $queryBuilder->getRestrictions()->removeAll();
105  $flexFormContent = $queryBuilder
106  ->select('pi_flexform')
107  ->from('tt_content')
108  ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(self::VALUE_ContentId, ‪Connection::PARAM_INT)))
109  ->executeQuery()
110  ->fetchOne();
111 
112  self::assertEquals($expected, $flexFormContent);
113  }
114 
119  {
120  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '<T3DataStructure>
121  <meta>
122  <langDisable>1</langDisable>
123  </meta>
124  <sheets>
125  <sheet1>
126  <ROOT>
127  <TCEforms>
128  <sheetTitle>Text Example with an RTE field</sheetTitle>
129  </TCEforms>
130  <type>array</type>
131  <el>
132  <settings.bodytext>
133  <label>Random Bodytext</label>
134  <config>
135  <type>text</type>
136  <rows>5</rows>
137  <cols>30</cols>
138  <eval>trim,required</eval>
139  <enableRichtext>1</enableRichtext>
140  <richtextConfiguration>default</richtextConfiguration>
141  </config>
142  </settings.bodytext>
143  </el>
144  </ROOT>
145  </sheet1>
146  </sheets>
147 </T3DataStructure>';
148 
149  $expected = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
150 <T3FlexForms>
151  <data>
152  <sheet index="sheet1">
153  <language index="lDEF">
154  <field index="settings.isNotDefined">1</field>
155  <field index="settings.bodytext">
156  <value index="vDEF">&lt;p class=&quot;align-right&quot;&gt;First line&lt;/p&gt;
157 &lt;p&gt;Last line&lt;/p&gt;</value>
158  </field>
159  </language>
160  </sheet>
161  </data>
162 </T3FlexForms>';
163 
164  $this->actionService->modifyRecords(1, [
165  'tt_content' => [
166  'uid' => self::VALUE_ContentId,
167  'pi_flexform' => [
168  'data' => [
169  'sheet1' => [
170  'lDEF' => [
171  'settings.isNotDefined' => '1',
172  'settings.bodytext' => [
173  'vDEF' => '<p class="align-right">First line</p>
174 
175 <p>Last line</p>',
176  ],
177  ],
178  ],
179  ],
180  ],
181  ],
182  ]);
183 
184  $queryBuilder = $this->getConnectionPool()
185  ->getQueryBuilderForTable('tt_content');
186  $queryBuilder->getRestrictions()->removeAll();
187  $flexFormContent = $queryBuilder
188  ->select('pi_flexform')
189  ->from('tt_content')
190  ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(self::VALUE_ContentId, ‪Connection::PARAM_INT)))
191  ->executeQuery()
192  ->fetchOne();
193 
194  self::assertEquals($expected, $flexFormContent);
195  }
196 }
‪TYPO3\CMS\Core\Database\Connection\PARAM_INT
‪const PARAM_INT
Definition: Connection.php:49
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\setUp
‪setUp()
Definition: ActionTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\transformationAppliesForRichTextFieldsWithoutSheets
‪transformationAppliesForRichTextFieldsWithoutSheets()
Definition: ActionTest.php:41
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\VALUE_ContentId
‪const VALUE_ContentId
Definition: ActionTest.php:25
‪TYPO3\CMS\Core\Database\Connection
Definition: Connection.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: ActionTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest
Definition: ActionTest.php:24
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\transformationAppliesForRichTextFieldsWithSheets
‪transformationAppliesForRichTextFieldsWithSheets()
Definition: ActionTest.php:118
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform
Definition: ActionTest.php:18