TYPO3 CMS  TYPO3_6-2
ExtensionUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
20 
21  public function setUp() {
22  $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array('fullQuoteStr', 'exec_SELECTgetRows'));
23 
24  $GLOBALS['TSFE'] = new \stdClass();
25  $GLOBALS['TSFE']->tmpl = new \stdClass();
26  $GLOBALS['TSFE']->tmpl->setup = array();
27  $GLOBALS['TSFE']->tmpl->setup['tt_content.']['list.']['20.'] = array(
28  '9' => 'CASE',
29  '9.' => array(
30  'key.' => array(
31  'field' => 'layout'
32  ),
33  0 => '< plugin.tt_news'
34  ),
35  'extensionname_someplugin' => 'USER',
36  'extensionname_someplugin.' => array(
37  'userFunc' => 'TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run',
38  'extensionName' => 'ExtensionName',
39  'pluginName' => 'SomePlugin'
40  ),
41  'someotherextensionname_secondplugin' => 'USER',
42  'someotherextensionname_secondplugin.' => array(
43  'userFunc' => 'TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run',
44  'extensionName' => 'SomeOtherExtensionName',
45  'pluginName' => 'SecondPlugin'
46  ),
47  'extensionname_thirdplugin' => 'USER',
48  'extensionname_thirdplugin.' => array(
49  'userFunc' => 'TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run',
50  'extensionName' => 'ExtensionName',
51  'pluginName' => 'ThirdPlugin'
52  )
53  );
54  }
55 
61  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
62  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('MyExtension', 'Pi1', array('Blog' => 'index'));
63  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
64  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
65  $this->assertContains('
66  userFunc = TYPO3\\CMS\\Extbase\\Core\\Bootstrap->run
67  extensionName = MyExtension
68  pluginName = Pi1', $staticTypoScript);
69  $this->assertNotContains('USER_INT', $staticTypoScript);
70  }
71 
77  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
78  \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin('MyExtension', 'Pi1', array('Blog' => 'index'));
79  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
80  $defaultTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'];
81  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
82  }
83 
89  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
91  'FirstController' => 'index'
92  ));
93  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
94  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
95  $this->assertContains('
96  extensionName = MyExtension
97  pluginName = Pi1', $staticTypoScript);
98  $expectedResult = array(
99  'controllers' => array(
100  'FirstController' => array(
101  'actions' => array('index')
102  )
103  ),
104  'pluginType' => 'list_type'
105  );
106  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
107  }
108 
116  'FirstController' => 'index'
117  ));
118  }
119 
127  'FirstController' => 'index'
128  ));
129  }
130 
136  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
138  'FirstController' => 'index,show,new, create,delete,edit,update'
139  ), array(
140  'FirstController' => 'index,show'
141  ));
142  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
143  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
144  $this->assertContains('
145  extensionName = MyExtension
146  pluginName = Pi1', $staticTypoScript);
147  $expectedResult = array(
148  'controllers' => array(
149  'FirstController' => array(
150  'actions' => array('index', 'show', 'new', 'create', 'delete', 'edit', 'update'),
151  'nonCacheableActions' => array('index', 'show')
152  )
153  ),
154  'pluginType' => 'list_type'
155  );
156  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
157  }
158 
164  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
166  'FirstController' => 'index,show,new, create,delete,edit,update'
167  ), array(
168  'FirstController' => 'new,show'
169  ));
170  $staticTypoScript = $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
171  $this->assertContains('tt_content.list.20.myextension_pi1 = USER', $staticTypoScript);
172  $this->assertContains('
173  extensionName = MyExtension
174  pluginName = Pi1', $staticTypoScript);
175  $expectedResult = array(
176  'controllers' => array(
177  'FirstController' => array(
178  'actions' => array('index', 'show', 'new', 'create', 'delete', 'edit', 'update'),
179  'nonCacheableActions' => array('new', 'show')
180  )
181  ),
182  'pluginType' => 'list_type'
183  );
184  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
185  }
186 
192  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
194  'FirstController' => 'index,show,new,create,delete,edit,update',
195  'SecondController' => 'index,show,delete',
196  'ThirdController' => 'create'
197  ), array(
198  'FirstController' => 'new,create,edit,update',
199  'ThirdController' => 'create'
200  ));
201  $expectedResult = array(
202  'controllers' => array(
203  'FirstController' => array(
204  'actions' => array('index', 'show', 'new', 'create', 'delete', 'edit', 'update'),
205  'nonCacheableActions' => array('new', 'create', 'edit', 'update')
206  ),
207  'SecondController' => array(
208  'actions' => array('index', 'show', 'delete')
209  ),
210  'ThirdController' => array(
211  'actions' => array('create'),
212  'nonCacheableActions' => array('create')
213  )
214  ),
215  'pluginType' => 'list_type'
216  );
217  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
218  }
219 
225  $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'] = array();
227  'FirstController' => 'index,show,new,create,delete,edit,update',
228  'SecondController' => 'index,show,delete',
229  'ThirdController' => 'create'
230  ), array(
231  'FirstController' => 'index,new,create,edit,update',
232  'SecondController' => 'delete',
233  'ThirdController' => 'create'
234  ));
235  $expectedResult = array(
236  'controllers' => array(
237  'FirstController' => array(
238  'actions' => array('index', 'show', 'new', 'create', 'delete', 'edit', 'update'),
239  'nonCacheableActions' => array('index', 'new', 'create', 'edit', 'update')
240  ),
241  'SecondController' => array(
242  'actions' => array('index', 'show', 'delete'),
243  'nonCacheableActions' => array('delete')
244  ),
245  'ThirdController' => array(
246  'actions' => array('create'),
247  'nonCacheableActions' => array('create')
248  )
249  ),
250  'pluginType' => 'list_type'
251  );
252  $this->assertEquals($expectedResult, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions']['MyExtension']['plugins']['Pi1']);
253  }
254 
262  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = array();
263  $GLOBALS['TYPO3_LOADED_EXT'] = array();
264  $GLOBALS['TYPO3_LOADED_EXT']['indexed_search']['ext_icon'] = 'foo.gif';
266  'indexed_search',
267  'Pi2',
268  'Testing'
269  );
270  $this->assertEquals(
271  'sysext/indexed_search/foo.gif',
272  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
273  );
274  }
275 
283  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = array();
284  $GLOBALS['TYPO3_LOADED_EXT'] = array();
285  $GLOBALS['TYPO3_LOADED_EXT']['indexed_search']['ext_icon'] = 'foo.gif';
287  'IndexedSearch',
288  'Pi2',
289  'Testing'
290  );
291  $this->assertEquals(
292  'sysext/indexed_search/foo.gif',
293  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
294  );
295  }
296 
304  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'] = array();
306  'IndexedSearch',
307  'Pi2',
308  'Testing',
309  'sysext/indexed_search/foo.gif'
310  );
311  $this->assertEquals(
312  'sysext/indexed_search/foo.gif',
313  $GLOBALS['TCA']['tt_content']['columns']['list_type']['config']['items'][0][2]
314  );
315  }
316 }
static registerPlugin($extensionName, $pluginName, $pluginTitle, $pluginIconPathAndFilename=NULL)
static configurePlugin($extensionName, $pluginName, array $controllerActions, array $nonCacheableControllerActions=array(), $pluginType=self::PLUGIN_TYPE_PLUGIN)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]