TYPO3 CMS  TYPO3_7-6
ExtensionUtilityTest.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 
21 {
22  protected function setUp()
23  {
24  $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, ['fullQuoteStr', 'exec_SELECTgetRows']);
25 
26  $GLOBALS['TSFE'] = new \stdClass();
27  $GLOBALS['TSFE']->tmpl = new \stdClass();
28  $GLOBALS['TSFE']->tmpl->setup = [];
29  $GLOBALS['TSFE']->tmpl->setup['tt_content.']['list.']['20.'] = [
30  '9' => 'CASE',
31  '9.' => [
32  'key.' => [
33  'field' => 'layout'
34  ],
35  0 => '< plugin.tt_news'
36  ],
37  'extensionname_someplugin' => 'USER',
38  'extensionname_someplugin.' => [
39  'userFunc' => \TYPO3\CMS\Extbase\Core\Bootstrap::class . '->run',
40  'extensionName' => 'ExtensionName',
41  'pluginName' => 'SomePlugin'
42  ],
43  'someotherextensionname_secondplugin' => 'USER',
44  'someotherextensionname_secondplugin.' => [
45  'userFunc' => \TYPO3\CMS\Extbase\Core\Bootstrap::class . '->run',
46  'extensionName' => 'SomeOtherExtensionName',
47  'pluginName' => 'SecondPlugin'
48  ],
49  'extensionname_thirdplugin' => 'USER',
50  'extensionname_thirdplugin.' => [
51  'userFunc' => \TYPO3\CMS\Extbase\Core\Bootstrap::class . '->run',
52  'extensionName' => 'ExtensionName',
53  'pluginName' => 'ThirdPlugin'
54  ]
55  ];
56  }
57 
63  {
64  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
65  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('MyExtension', 'Pi1', ['Blog' => 'index']);
66  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
67  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
68  $this->assertContains('
69  userFunc = TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run
70  extensionName = MyExtension
71  pluginName = Pi1', $staticTypoScript);
72  $this->assertNotContains('USER_INT', $staticTypoScript);
73  }
74 
80  {
81  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
82  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('MyExtension', 'Pi1', ['Blog' => 'index']);
83  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
84  $defaultTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'];
85  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
86  }
87 
93  {
94  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
96  'FirstController' => 'index'
97  ]);
98  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
99  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
100  $this->assertContains('
101  extensionName = MyExtension
102  pluginName = Pi1', $staticTypoScript);
103  $expectedResult = [
104  'controllers' => [
105  'FirstController' => [
106  'actions' => ['index']
107  ]
108  ],
109  'pluginType' => 'list_type'
110  ];
111  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
112  }
113 
120  {
122  'FirstController' => 'index'
123  ]);
124  }
125 
132  {
134  'FirstController' => 'index'
135  ]);
136  }
137 
143  {
144  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
146  'FirstController' => 'index,show,new, create,delete,edit,update'
147  ], [
148  'FirstController' => 'index,show'
149  ]);
150  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
151  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
152  $this->assertContains('
153  extensionName = MyExtension
154  pluginName = Pi1', $staticTypoScript);
155  $expectedResult = [
156  'controllers' => [
157  'FirstController' => [
158  'actions' => ['index', 'show', 'new', 'create', 'delete', 'edit', 'update'],
159  'nonCacheableActions' => ['index', 'show']
160  ]
161  ],
162  'pluginType' => 'list_type'
163  ];
164  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
165  }
166 
172  {
173  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
175  'FirstController' => 'index,show,new, create,delete,edit,update'
176  ], [
177  'FirstController' => 'new,show'
178  ]);
179  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
180  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
181  $this->assertContains('
182  extensionName = MyExtension
183  pluginName = Pi1', $staticTypoScript);
184  $expectedResult = [
185  'controllers' => [
186  'FirstController' => [
187  'actions' => ['index', 'show', 'new', 'create', 'delete', 'edit', 'update'],
188  'nonCacheableActions' => ['new', 'show']
189  ]
190  ],
191  'pluginType' => 'list_type'
192  ];
193  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
194  }
195 
201  {
202  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
204  'FirstController' => 'index,show,new,create,delete,edit,update',
205  'SecondController' => 'index,show,delete',
206  'ThirdController' => 'create'
207  ], [
208  'FirstController' => 'new,create,edit,update',
209  'ThirdController' => 'create'
210  ]);
211  $expectedResult = [
212  'controllers' => [
213  'FirstController' => [
214  'actions' => ['index', 'show', 'new', 'create', 'delete', 'edit', 'update'],
215  'nonCacheableActions' => ['new', 'create', 'edit', 'update']
216  ],
217  'SecondController' => [
218  'actions' => ['index', 'show', 'delete']
219  ],
220  'ThirdController' => [
221  'actions' => ['create'],
222  'nonCacheableActions' => ['create']
223  ]
224  ],
225  'pluginType' => 'list_type'
226  ];
227  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
228  }
229 
235  {
236  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = [];
238  'FirstController' => 'index,show,new,create,delete,edit,update',
239  'SecondController' => 'index,show,delete',
240  'ThirdController' => 'create'
241  ], [
242  'FirstController' => 'index,new,create,edit,update',
243  'SecondController' => 'delete',
244  'ThirdController' => 'create'
245  ]);
246  $expectedResult = [
247  'controllers' => [
248  'FirstController' => [
249  'actions' => ['index', 'show', 'new', 'create', 'delete', 'edit', 'update'],
250  'nonCacheableActions' => ['index', 'new', 'create', 'edit', 'update']
251  ],
252  'SecondController' => [
253  'actions' => ['index', 'show', 'delete'],
254  'nonCacheableActions' => ['delete']
255  ],
256  'ThirdController' => [
257  'actions' => ['create'],
258  'nonCacheableActions' => ['create']
259  ]
260  ],
261  'pluginType' => 'list_type'
262  ];
263  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
264  }
265 
273  {
274  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = [];
275  $GLOBALS['TYPO3_LOADED_EXT'] = [];
276  $GLOBALS['TYPO3_LOADED_EXT']['indexed_search']['ext_icon'] = 'foo.gif';
278  'indexed_search',
279  'Pi2',
280  'Testing'
281  );
282  $this->assertEquals(
283  'EXT:indexed_search/foo.gif',
284  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
285  );
286  }
287 
295  {
296  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = [];
297  $GLOBALS['TYPO3_LOADED_EXT'] = [];
298  $GLOBALS['TYPO3_LOADED_EXT']['indexed_search']['ext_icon'] = 'foo.gif';
300  'IndexedSearch',
301  'Pi2',
302  'Testing'
303  );
304  $this->assertEquals(
305  'EXT:indexed_search/foo.gif',
306  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
307  );
308  }
309 
317  {
318  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = [];
320  'IndexedSearch',
321  'Pi2',
322  'Testing',
323  'EXT:indexed_search/foo.gif'
324  );
325  $this->assertEquals(
326  'EXT:indexed_search/foo.gif',
327  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
328  );
329  }
330 }
static configurePlugin($extensionName, $pluginName, array $controllerActions, array $nonCacheableControllerActions=[], $pluginType=self::PLUGIN_TYPE_PLUGIN)
static registerPlugin($extensionName, $pluginName, $pluginTitle, $pluginIconPathAndFilename=null)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']