TYPO3 CMS  TYPO3_6-2
AbstractMenuContentObjectTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  protected $fixture = NULL;
27 
31  public function setUp() {
32  $proxy = $this->buildAccessibleProxy('TYPO3\\CMS\\Frontend\\ContentObject\\Menu\\AbstractMenuContentObject');
33  $this->fixture = new $proxy();
34  $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection');
35  $GLOBALS['TSFE'] = $this->getMock('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', array(), array($GLOBALS['TYPO3_CONF_VARS'], 1, 1));
36  $GLOBALS['TSFE']->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
37  $GLOBALS['TSFE']->page = array();
38  }
39 
41  // Tests concerning sectionIndex
43 
48  protected function prepareSectionIndexTest() {
49  $this->fixture->sys_page = $this->getMock('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
50  $this->fixture->parent_cObj = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
51  }
52 
57  $this->prepareSectionIndexTest();
58  $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(NULL));
59  $result = $this->fixture->_call('sectionIndex', 'field');
60  $this->assertEquals($result, array());
61  }
62 
67  $this->prepareSectionIndexTest();
68  $this->fixture->id = 10;
69  $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(NULL))->with(10);
70  $result = $this->fixture->_call('sectionIndex', 'field');
71  $this->assertEquals($result, array());
72  }
73 
79  $this->prepareSectionIndexTest();
80  $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(array()));
81  $this->fixture->parent_cObj->expects($this->once())->method('exec_getQuery')->will($this->returnValue(0));
82  $this->fixture->_call('sectionIndex', 'field');
83  }
84 
89  $this->prepareSectionIndexTest();
90  $this->fixture->mconf['sectionIndex.']['type'] = 'all';
91  $GLOBALS['TSFE']->sys_language_contentOL = 1;
92  $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(array('_PAGES_OVERLAY_LANGUAGE' => 1)));
93  $this->fixture->parent_cObj->expects($this->once())->method('exec_getQuery')->will($this->returnValue(1));
94  $GLOBALS['TYPO3_DB']->expects($this->exactly(2))->method('sql_fetch_assoc')->will($this->onConsecutiveCalls($this->returnValue(array('uid' => 0, 'header' => 'NOT_OVERLAID')), $this->returnValue(FALSE)));
95  $this->fixture->sys_page->expects($this->once())->method('getRecordOverlay')->will($this->returnValue(array('uid' => 0, 'header' => 'OVERLAID')));
96  $result = $this->fixture->_call('sectionIndex', 'field');
97  $this->assertEquals($result[0]['title'], 'OVERLAID');
98  }
99 
104  return array(
105  'unfiltered fields' => array(
106  1,
107  array(
108  'sectionIndex' => 1,
109  'header' => 'foo',
110  'header_layout' => 1
111  )
112  ),
113  'with unset section index' => array(
114  0,
115  array(
116  'sectionIndex' => 0,
117  'header' => 'foo',
118  'header_layout' => 1
119  )
120  ),
121  'with unset header' => array(
122  0,
123  array(
124  'sectionIndex' => 1,
125  'header' => '',
126  'header_layout' => 1
127  )
128  ),
129  'with header layout 100' => array(
130  0,
131  array(
132  'sectionIndex' => 1,
133  'header' => 'foo',
134  'header_layout' => 100
135  )
136  )
137  );
138  }
139 
146  public function sectionIndexFilters($expectedAmount, array $dataRow) {
147  $this->prepareSectionIndexTest();
148  $this->fixture->mconf['sectionIndex.']['type'] = 'header';
149  $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(array()));
150  $this->fixture->parent_cObj->expects($this->once())->method('exec_getQuery')->will($this->returnValue(1));
151  $GLOBALS['TYPO3_DB']->expects($this->exactly(2))->method('sql_fetch_assoc')->will($this->onConsecutiveCalls($this->returnValue($dataRow), $this->returnValue(FALSE)));
152  $result = $this->fixture->_call('sectionIndex', 'field');
153  $this->assertCount($expectedAmount, $result);
154  }
155 
160  return array(
161  'no configuration' => array(
162  array(),
163  'colPos=0'
164  ),
165  'with useColPos 2' => array(
166  array('useColPos' => 2),
167  'colPos=2'
168  ),
169  'with useColPos -1' => array(
170  array('useColPos' => -1),
171  ''
172  ),
173  'with stdWrap useColPos' => array(
174  array(
175  'useColPos.' => array(
176  'wrap' => '2|'
177  )
178  ),
179  'colPos=2'
180  )
181  );
182  }
183 
190  public function sectionIndexQueriesWithDifferentColPos($configuration, $whereClausePrefix) {
191  $this->prepareSectionIndexTest();
192  $this->fixture->sys_page->expects($this->once())->method('getPage')->will($this->returnValue(array()));
193  $this->fixture->mconf['sectionIndex.'] = $configuration;
194  $queryConfiguration = array(
195  'pidInList' => 12,
196  'orderBy' => 'field',
197  'languageField' => 'sys_language_uid',
198  'where' => $whereClausePrefix
199  );
200  $this->fixture->parent_cObj->expects($this->once())->method('exec_getQuery')->with('tt_content', $queryConfiguration)->will($this->returnValue(1));
201  $this->fixture->_call('sectionIndex', 'field', 12);
202  }
203 
205  // Tests concerning menu item states
207 
211  return array(
212  'none excluded' => array (
213  array(12, 34, 56),
214  '1, 23, 456',
215  TRUE
216  ),
217  'one excluded' => array (
218  array(1, 234, 567),
219  '1, 23, 456',
220  TRUE
221  ),
222  'three excluded' => array (
223  array(1, 23, 456),
224  '1, 23, 456',
225  FALSE
226  ),
227  'empty excludeList' => array (
228  array(1, 123, 45),
229  '',
230  TRUE
231  ),
232  'empty menu' => array (
233  array(),
234  '1, 23, 456',
235  FALSE
236  ),
237  );
238 
239  }
240 
248  public function ifsubHasToCheckExcludeUidList($menuItems, $excludeUidList, $expectedResult) {
249  $menu = array();
250  foreach ($menuItems as $page) {
251  $menu[] = array('uid' => $page);
252  }
253 
254  $this->prepareSectionIndexTest();
255  $this->fixture->parent_cObj = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer', array());
256 
257  $this->fixture->sys_page->expects($this->once())->method('getMenu')->will($this->returnValue($menu));
258  $this->fixture->menuArr = array(
259  0 => array('uid' => 1)
260  );
261  $this->fixture->conf['excludeUidList'] = $excludeUidList;
262 
263  $this->assertEquals($expectedResult, $this->fixture->isItemState('IFSUB', 0));
264  }
265 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]