2 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject\Menu;
33 $proxyClassName = $this->buildAccessibleProxy(\TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::class);
34 $this->subject = $this->getMockForAbstractClass($proxyClassName);
35 $GLOBALS[
'TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
36 $GLOBALS[
'TSFE'] = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array(
$GLOBALS[
'TYPO3_CONF_VARS'], 1, 1));
37 $GLOBALS[
'TSFE']->cObj = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
51 $this->subject->sys_page = $this->getMock(\TYPO3\CMS\Frontend\Page\PageRepository::class);
52 $this->subject->parent_cObj = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class);
61 $this->subject->sys_page->expects($this->once())->method(
'getPage')->will($this->returnValue(null));
62 $result = $this->subject->_call(
'sectionIndex',
'field');
63 $this->assertEquals($result, array());
72 $this->subject->id = 10;
73 $this->subject->sys_page->expects($this->once())->method(
'getPage')->will($this->returnValue(null))->with(10);
74 $result = $this->subject->_call(
'sectionIndex',
'field');
75 $this->assertEquals($result, array());
85 $this->subject->sys_page->expects($this->once())->method(
'getPage')->will($this->returnValue(array()));
86 $this->subject->parent_cObj->expects($this->once())->method(
'exec_getQuery')->will($this->returnValue(0));
87 $this->subject->_call(
'sectionIndex',
'field');
96 $this->subject->mconf[
'sectionIndex.'][
'type'] =
'all';
97 $GLOBALS[
'TSFE']->sys_language_contentOL = 1;
98 $this->subject->sys_page->expects($this->once())->method(
'getPage')->will($this->returnValue(array(
'_PAGES_OVERLAY_LANGUAGE' => 1)));
99 $this->subject->parent_cObj->expects($this->once())->method(
'exec_getQuery')->will($this->returnValue(1));
100 $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)));
101 $this->subject->sys_page->expects($this->once())->method(
'getRecordOverlay')->will($this->returnValue(array(
'uid' => 0,
'header' =>
'OVERLAID')));
102 $result = $this->subject->_call(
'sectionIndex',
'field');
103 $this->assertEquals($result[0][
'title'],
'OVERLAID');
112 'unfiltered fields' => array(
120 'with unset section index' => array(
128 'with unset header' => array(
136 'with header layout 100' => array(
141 'header_layout' => 100
156 $this->subject->mconf[
'sectionIndex.'][
'type'] =
'header';
157 $this->subject->sys_page->expects($this->once())->method(
'getPage')->will($this->returnValue(array()));
158 $this->subject->parent_cObj->expects($this->once())->method(
'exec_getQuery')->will($this->returnValue(1));
159 $GLOBALS[
'TYPO3_DB']->expects($this->exactly(2))->method(
'sql_fetch_assoc')->will($this->onConsecutiveCalls($this->returnValue($dataRow), $this->returnValue(
false)));
160 $result = $this->subject->_call(
'sectionIndex',
'field');
161 $this->assertCount($expectedAmount, $result);
170 'no configuration' => array(
174 'with useColPos 2' => array(
175 array(
'useColPos' => 2),
178 'with useColPos -1' => array(
179 array(
'useColPos' => -1),
182 'with stdWrap useColPos' => array(
184 'useColPos.' => array(
202 $this->subject->sys_page->expects($this->once())->method(
'getPage')->will($this->returnValue(array()));
203 $this->subject->mconf[
'sectionIndex.'] = $configuration;
204 $queryConfiguration = array(
206 'orderBy' =>
'field',
207 'languageField' =>
'sys_language_uid',
208 'where' => $whereClausePrefix
210 $this->subject->parent_cObj->expects($this->once())->method(
'exec_getQuery')->with(
'tt_content', $queryConfiguration)->will($this->returnValue(1));
211 $this->subject->_call(
'sectionIndex',
'field', 12);
223 'none excluded' => array(
228 'one excluded' => array(
233 'three excluded' => array(
238 'empty excludeList' => array(
243 'empty menu' => array(
261 foreach ($menuItems as $page) {
262 $menu[] = array(
'uid' => $page);
266 $this->subject->parent_cObj = $this->getMock(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class, array());
268 $this->subject->sys_page->expects($this->once())->method(
'getMenu')->will($this->returnValue($menu));
269 $this->subject->menuArr = array(
270 0 => array(
'uid' => 1)
272 $this->subject->conf[
'excludeUidList'] = $excludeUidList;
274 $this->assertEquals($expectedResult, $this->subject->isItemState(
'IFSUB', 0));