‪TYPO3CMS  10.4
ActionTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 
21 {
22  const ‪VALUE_ContentId = 100;
26  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Flexform/DataSet/';
27 
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  $this->‪importScenarioDataSet('LiveDefaultPages');
32  $this->‪importScenarioDataSet('LiveDefaultElements');
33  }
34 
39  {
40  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '<?xml version="1.0" encoding="UTF-8"?>
41 <T3DataStructure>
42  <meta>
43  <langDisable>0</langDisable>
44  </meta>
45  <ROOT type="array">
46  <type>array</type>
47  <el type="array">
48  <settings.bodytext>
49  <TCEforms type="array">
50  <label>Random Bodytext</label>
51  <config type="array">
52  <type>text</type>
53  <cols>48</cols>
54  <rows>5</rows>
55  <enableRichtext>1</enableRichtext>
56  <richtextConfiguration>default</richtextConfiguration>
57  </config>
58  </TCEforms>
59  </settings.bodytext>
60  </el>
61  </ROOT>
62 </T3DataStructure>';
63 
64  $expected = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
65 <T3FlexForms>
66  <data>
67  <sheet index="sDEF">
68  <language index="lDEF">
69  <field index="settings.isNotDefined">1</field>
70  <field index="settings.bodytext">
71  <value index="vDEF">&lt;p class=&quot;align-right&quot;&gt;First line&lt;/p&gt;
72 &lt;p&gt;Last line&lt;/p&gt;</value>
73  </field>
74  </language>
75  </sheet>
76  </data>
77 </T3FlexForms>';
78 
79  $this->‪getActionService()->modifyRecords(1, [
80  'tt_content' => [
81  'uid' => self::VALUE_ContentId,
82  'pi_flexform' => [
83  'data' => [
84  'sDEF' => [
85  'lDEF' => [
86  'settings.isNotDefined' => '1',
87  'settings.bodytext' => [
88  'vDEF' => '<p class="align-right">First line</p>
89 
90 <p>Last line</p>'
91  ]
92  ]
93  ]
94  ]
95  ]
96  ]
97  ]);
98 
99  $queryBuilder = $this->getConnectionPool()
100  ->getQueryBuilderForTable('tt_content');
101  $queryBuilder->getRestrictions()->removeAll();
102  $flexFormContent = $queryBuilder
103  ->select('pi_flexform')
104  ->from('tt_content')
105  ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(self::VALUE_ContentId, \PDO::PARAM_INT)))
106  ->execute()
107  ->fetchColumn(0);
108 
109  self::assertEquals($expected, $flexFormContent);
110  }
111 
116  {
117  ‪$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['default'] = '<T3DataStructure>
118  <meta>
119  <langDisable>1</langDisable>
120  </meta>
121  <sheets>
122  <sheet1>
123  <ROOT>
124  <TCEforms>
125  <sheetTitle>Text Example with an RTE field</sheetTitle>
126  </TCEforms>
127  <type>array</type>
128  <el>
129  <settings.bodytext>
130  <label>Random Bodytext</label>
131  <config>
132  <type>text</type>
133  <rows>5</rows>
134  <cols>30</cols>
135  <eval>trim,required</eval>
136  <enableRichtext>1</enableRichtext>
137  <richtextConfiguration>default</richtextConfiguration>
138  </config>
139  </settings.bodytext>
140  </el>
141  </ROOT>
142  </sheet1>
143  </sheets>
144 </T3DataStructure>';
145 
146  $expected = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
147 <T3FlexForms>
148  <data>
149  <sheet index="sheet1">
150  <language index="lDEF">
151  <field index="settings.isNotDefined">1</field>
152  <field index="settings.bodytext">
153  <value index="vDEF">&lt;p class=&quot;align-right&quot;&gt;First line&lt;/p&gt;
154 &lt;p&gt;Last line&lt;/p&gt;</value>
155  </field>
156  </language>
157  </sheet>
158  </data>
159 </T3FlexForms>';
160 
161  $this->‪getActionService()->modifyRecords(1, [
162  'tt_content' => [
163  'uid' => self::VALUE_ContentId,
164  'pi_flexform' => [
165  'data' => [
166  'sheet1' => [
167  'lDEF' => [
168  'settings.isNotDefined' => '1',
169  'settings.bodytext' => [
170  'vDEF' => '<p class="align-right">First line</p>
171 
172 <p>Last line</p>'
173  ]
174  ]
175  ]
176  ]
177  ]
178  ]
179  ]);
180 
181  $queryBuilder = $this->getConnectionPool()
182  ->getQueryBuilderForTable('tt_content');
183  $queryBuilder->getRestrictions()->removeAll();
184  $flexFormContent = $queryBuilder
185  ->select('pi_flexform')
186  ->from('tt_content')
187  ->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter(self::VALUE_ContentId, \PDO::PARAM_INT)))
188  ->execute()
189  ->fetchColumn(0);
190 
191  self::assertEquals($expected, $flexFormContent);
192  }
193 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\setUp
‪setUp()
Definition: ActionTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\transformationAppliesForRichTextFieldsWithoutSheets
‪transformationAppliesForRichTextFieldsWithoutSheets()
Definition: ActionTest.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\VALUE_ContentId
‪const VALUE_ContentId
Definition: ActionTest.php:22
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\getActionService
‪ActionService getActionService()
Definition: AbstractDataHandlerActionTestCase.php:191
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest
Definition: ActionTest.php:21
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\transformationAppliesForRichTextFieldsWithSheets
‪transformationAppliesForRichTextFieldsWithSheets()
Definition: ActionTest.php:114
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform\ActionTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: ActionTest.php:25
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Flexform
Definition: ActionTest.php:16
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:201