2 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
57 protected function setUp()
60 $this->contentObjectRenderer = $this->getMock(
61 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class
63 $this->subject = $this->getAccessibleMock(
64 \TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject::class,
65 array(
'initializeStandaloneViewInstance'),
66 array($this->contentObjectRenderer)
69 $tsfe = $this->getMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class, array(), array(),
'',
false);
70 $tsfe->tmpl = $this->getMock(\TYPO3\CMS\Core\TypoScript\TemplateService::class);
88 $this->standaloneView = $this->getMock(\TYPO3\CMS\Fluid\View\StandaloneView::class, array(), array(),
'',
false);
89 $this->request = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Request::class);
91 ->expects($this->any())
92 ->method(
'getRequest')
93 ->will($this->returnValue($this->request));
94 $this->subject->_set(
'view', $this->standaloneView);
102 $this->assertSame($this->contentObjectRenderer, $this->subject->getContentObject());
112 ->expects($this->once())
113 ->method(
'initializeStandaloneViewInstance');
114 $this->subject->render(array());
120 public function renderCallsTemplateServiceGetFileNameForGivenTemplateFile()
124 $templateService =
$GLOBALS[
'TSFE']->tmpl;
126 ->expects($this->any())
127 ->method(
'getFileName')
129 $this->subject->render(array(
'file' =>
'foo'));
138 $this->contentObjectRenderer
139 ->expects($this->any())
141 ->with(
'foo', array(
'bar' =>
'baz'));
142 $this->subject->render(array(
'file' =>
'foo',
'file.' => array(
'bar' =>
'baz')));
151 $this->contentObjectRenderer
152 ->expects($this->at(0))
154 ->with(
'dummyPath', array(
'wrap' =>
'|5/'));
155 $this->contentObjectRenderer
156 ->expects($this->at(1))
158 ->with(
'', array(
'field' =>
'someField'));
159 $this->subject->render(array(
160 'templateName' =>
'foobar',
161 'templateRootPaths.' => array(
168 'field' =>
'someField',
178 public function renderSetsTemplateFileInView()
182 $templateService =
$GLOBALS[
'TSFE']->tmpl;
184 ->expects($this->any())
185 ->method(
'getFileName')
187 ->will($this->returnValue(
'bar'));
188 $this->standaloneView
189 ->expects($this->any())
190 ->method(
'setTemplatePathAndFilename')
191 ->with(PATH_site .
'bar');
192 $this->subject->render(array(
'file' =>
'foo'));
202 $this->contentObjectRenderer
203 ->expects($this->any())
204 ->method(
'cObjGetSingle')
205 ->with(
'FILE', array(
'file' => PATH_site .
'foo/bar.html'))
206 ->will($this->returnValue(
'baz'));
208 $this->standaloneView
209 ->expects($this->any())
210 ->method(
'setTemplateSource')
213 $this->subject->render(array(
214 'template' =>
'FILE',
215 'template.' => array(
216 'file' => PATH_site .
'foo/bar.html'
228 $this->standaloneView
229 ->expects($this->any())
230 ->method(
'getFormat')
231 ->will($this->returnValue(
'html'));
232 $this->standaloneView
233 ->expects($this->once())
234 ->method(
'setTemplate')
237 $this->subject->render(array(
238 'templateName' =>
'foo',
239 'templateRootPaths.' => array(
253 $this->contentObjectRenderer
254 ->expects($this->once())
256 ->with(
'TEXT', array(
'value' =>
'bar'))
257 ->will($this->returnValue(
'bar'));
258 $this->standaloneView
259 ->expects($this->any())
260 ->method(
'getFormat')
261 ->will($this->returnValue(
'html'));
262 $this->standaloneView
263 ->expects($this->once())
264 ->method(
'setTemplate')
267 $this->subject->render(array(
268 'templateName' =>
'TEXT',
269 'templateName.' => array(
'value' =>
'bar'),
270 'templateRootPaths.' => array(
283 $this->standaloneView
284 ->expects($this->once())
285 ->method(
'setLayoutRootPaths')
286 ->with(array(PATH_site .
'foo/bar.html'));
287 $this->subject->render(array(
'layoutRootPath' =>
'foo/bar.html'));
296 $this->contentObjectRenderer
297 ->expects($this->once())
299 ->with(
'foo', array(
'bar' =>
'baz'));
300 $this->subject->render(array(
'layoutRootPath' =>
'foo',
'layoutRootPath.' => array(
'bar' =>
'baz')));
309 $this->contentObjectRenderer
310 ->expects($this->at(0))
312 ->with(
'FILE', array(
'file' =>
'foo/bar.html'));
313 $this->subject->render(
315 'layoutRootPaths.' => array(
318 'file' =>
'foo/bar.html',
320 20 =>
'foo/bar2.html',
332 $this->standaloneView
333 ->expects($this->once())
334 ->method(
'setLayoutRootPaths')
335 ->with(array(10 => PATH_site .
'foo/bar.html', 20 => PATH_site .
'foo/bar2.html'));
336 $this->subject->render(array(
'layoutRootPaths.' => array(10 =>
'foo/bar.html', 20 =>
'foo/bar2.html')));
345 $this->standaloneView
346 ->expects($this->once())
347 ->method(
'setLayoutRootPaths')
348 ->with(array(0 => PATH_site .
'foo/main.html', 10 => PATH_site .
'foo/bar.html', 20 => PATH_site .
'foo/bar2.html'));
349 $this->subject->render(array(
'layoutRootPath' =>
'foo/main.html',
'layoutRootPaths.' => array(10 =>
'foo/bar.html', 20 =>
'foo/bar2.html')));
358 $this->standaloneView
359 ->expects($this->once())
360 ->method(
'setPartialRootPaths')
361 ->with(array(PATH_site .
'foo/bar.html'));
362 $this->subject->render(array(
'partialRootPath' =>
'foo/bar.html'));
371 $this->contentObjectRenderer
372 ->expects($this->at(0))
374 ->with(
'FILE', array(
'file' =>
'foo/bar.html'));
375 $this->subject->render(
377 'partialRootPaths.' => array(
380 'file' =>
'foo/bar.html',
382 20 =>
'foo/bar2.html',
394 $this->contentObjectRenderer
395 ->expects($this->once())
397 ->with(
'foo', array(
'bar' =>
'baz'));
398 $this->subject->render(array(
'partialRootPath' =>
'foo',
'partialRootPath.' => array(
'bar' =>
'baz')));
408 $this->standaloneView
409 ->expects($this->once())
410 ->method(
'setPartialRootPaths')
411 ->with(array(10 => PATH_site .
'foo', 20 => PATH_site .
'bar'));
412 $this->subject->render(array(
'partialRootPaths.' => array(10 =>
'foo', 20 =>
'bar')));
421 $this->standaloneView
422 ->expects($this->once())
423 ->method(
'setPartialRootPaths')
424 ->with(array(0 => PATH_site .
'main', 10 => PATH_site .
'foo', 20 => PATH_site .
'bar'));
425 $this->subject->render(array(
'partialRootPath' =>
'main',
'partialRootPaths.' => array(10 =>
'foo', 20 =>
'bar')));
434 $this->standaloneView
435 ->expects($this->once())
436 ->method(
'setFormat')
438 $this->subject->render(array(
'format' =>
'xml'));
447 $this->contentObjectRenderer
448 ->expects($this->once())
450 ->with(
'foo', array(
'bar' =>
'baz'));
451 $this->subject->render(array(
'format' =>
'foo',
'format.' => array(
'bar' =>
'baz')));
461 ->expects($this->once())
462 ->method(
'setPluginName')
464 $configuration = array(
466 'pluginName' =>
'foo',
469 $this->subject->render($configuration);
478 $this->contentObjectRenderer
479 ->expects($this->once())
481 ->with(
'foo', array(
'bar' =>
'baz'));
482 $configuration = array(
484 'pluginName' =>
'foo',
485 'pluginName.' => array(
490 $this->subject->render($configuration);
500 ->expects($this->once())
501 ->method(
'setControllerExtensionName')
503 $configuration = array(
505 'controllerExtensionName' =>
'foo',
508 $this->subject->render($configuration);
517 $this->contentObjectRenderer
518 ->expects($this->once())
520 ->with(
'foo', array(
'bar' =>
'baz'));
521 $configuration = array(
523 'controllerExtensionName' =>
'foo',
524 'controllerExtensionName.' => array(
529 $this->subject->render($configuration);
539 ->expects($this->once())
540 ->method(
'setControllerName')
542 $configuration = array(
544 'controllerName' =>
'foo',
547 $this->subject->render($configuration);
556 $this->contentObjectRenderer
557 ->expects($this->once())
559 ->with(
'foo', array(
'bar' =>
'baz'));
560 $configuration = array(
562 'controllerName' =>
'foo',
563 'controllerName.' => array(
568 $this->subject->render($configuration);
578 ->expects($this->once())
579 ->method(
'setControllerActionName')
581 $configuration = array(
583 'controllerActionName' =>
'foo',
586 $this->subject->render($configuration);
595 $this->contentObjectRenderer
596 ->expects($this->once())
598 ->with(
'foo', array(
'bar' =>
'baz'));
599 $configuration = array(
601 'controllerActionName' =>
'foo',
602 'controllerActionName.' => array(
607 $this->subject->render($configuration);
613 public function renderAssignsSettingsArrayToView()
617 $configuration = array(
618 'settings.' => array(
626 $expectedSettingsToBeSet = array(
634 $typoScriptServiceMock = $this->getMock(\TYPO3\CMS\Extbase\Service\TypoScriptService::class);
635 $typoScriptServiceMock
636 ->expects($this->once())
637 ->method(
'convertTypoScriptArrayToPlainArray')
638 ->with($configuration[
'settings.'])
639 ->will($this->returnValue($expectedSettingsToBeSet));
642 $this->standaloneView
643 ->expects($this->at(1))
645 ->with(
'settings', $expectedSettingsToBeSet);
647 $this->subject->render($configuration);
657 $configuration = array(
658 'variables.' => array(
665 $this->subject->render($configuration);
675 $configuration = array(
676 'variables.' => array(
683 $this->subject->render($configuration);
692 $configuration = array(
693 'variables.' => array(
700 $this->contentObjectRenderer
701 ->expects($this->once())
702 ->method(
'cObjGetSingle')
703 ->with(
'TEXT', array(
'value' =>
'foo'));
704 $this->subject->render($configuration);
713 $configuration = array(
714 'variables.' => array(
721 $this->contentObjectRenderer
722 ->expects($this->once())
723 ->method(
'cObjGetSingle')
724 ->will($this->returnValue(
'foo'));
725 $this->standaloneView
726 ->expects($this->once())
727 ->method(
'assignMultiple')
728 ->with(array(
'aVar' =>
'foo',
'data' => array(),
'current' => null));
729 $this->subject->render($configuration);
738 $this->contentObjectRenderer->data = array(
'foo');
739 $this->standaloneView
740 ->expects($this->once())
741 ->method(
'assignMultiple')
742 ->with(array(
'data' => array(
'foo'),
'current' => null));
743 $this->subject->render(array());
752 $this->contentObjectRenderer->data = array(
'currentKey' =>
'currentValue');
753 $this->contentObjectRenderer->currentValKey =
'currentKey';
754 $this->standaloneView
755 ->expects($this->once())
756 ->method(
'assignMultiple')
757 ->with(array(
'data' => array(
'currentKey' =>
'currentValue'),
'current' =>
'currentValue'));
758 $this->subject->render(array());
767 $this->standaloneView
768 ->expects($this->once())
770 $this->subject->render(array());
779 $configuration = array(
784 $this->standaloneView
785 ->expects($this->any())
787 ->will($this->returnValue(
'baz'));
788 $this->contentObjectRenderer
789 ->expects($this->once())
791 ->with(
'baz', array(
'foo' =>
'bar'));
792 $this->subject->render($configuration);