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