54fe0a87fdc9d8f34e18dfc913a26a3d659d8faf
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Tests / Unit / ContentObject / FluidTemplateContentObjectTest.php
1 <?php
2 namespace TYPO3\CMS\Frontend\Tests\Unit\ContentObject;
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
17 use TYPO3\CMS\Core\Page\PageRenderer;
18 use TYPO3\CMS\Core\TypoScript\TypoScriptService;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Extbase\Mvc\Request;
21 use TYPO3\CMS\Fluid\View\StandaloneView;
22 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
23 use TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject;
24 use TYPO3Fluid\Fluid\View\TemplateView;
25
26 /**
27 * Testcase
28 */
29 class FluidTemplateContentObjectTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
30 {
31 /**
32 * @var array A backup of registered singleton instances
33 */
34 protected $singletonInstances = [];
35
36 /**
37 * @var FluidTemplateContentObject|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
38 */
39 protected $subject = null;
40
41 /**
42 * @var ContentObjectRenderer|\PHPUnit_Framework_MockObject_MockObject
43 */
44 protected $contentObjectRenderer = null;
45
46 /**
47 * @var StandaloneView|\PHPUnit_Framework_MockObject_MockObject
48 */
49 protected $standaloneView = null;
50
51 /**
52 * @var Request|\PHPUnit_Framework_MockObject_MockObject
53 */
54 protected $request = null;
55
56 /**
57 * Set up
58 */
59 protected function setUp()
60 {
61 $this->singletonInstances = GeneralUtility::getSingletonInstances();
62 $this->contentObjectRenderer = $this->getMockBuilder(
63 \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class
64 )->getMock();
65 $this->subject = $this->getAccessibleMock(
66 \TYPO3\CMS\Frontend\ContentObject\FluidTemplateContentObject::class,
67 ['initializeStandaloneViewInstance'],
68 [$this->contentObjectRenderer]
69 );
70 /** @var $tsfe \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController */
71 $tsfe = $this->createMock(\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::class);
72 $tsfe->tmpl = $this->getMockBuilder(\TYPO3\CMS\Core\TypoScript\TemplateService::class)->getMock();
73 $GLOBALS['TSFE'] = $tsfe;
74 }
75
76 /**
77 * Tear down
78 */
79 protected function tearDown()
80 {
81 GeneralUtility::resetSingletonInstances($this->singletonInstances);
82 parent::tearDown();
83 }
84
85 /**
86 * Add a mock standalone view to subject
87 */
88 protected function addMockViewToSubject()
89 {
90 $this->standaloneView = $this->createMock(\TYPO3\CMS\Fluid\View\StandaloneView::class);
91 $this->request = $this->getMockBuilder(\TYPO3\CMS\Extbase\Mvc\Request::class)->getMock();
92 $this->standaloneView
93 ->expects($this->any())
94 ->method('getRequest')
95 ->will($this->returnValue($this->request));
96 $this->subject->_set('view', $this->standaloneView);
97 }
98
99 /**
100 * @test
101 */
102 public function constructSetsContentObjectRenderer()
103 {
104 $this->assertSame($this->contentObjectRenderer, $this->subject->getContentObjectRenderer());
105 }
106
107 /**
108 * @test
109 */
110 public function renderCallsInitializeStandaloneViewInstance()
111 {
112 $this->addMockViewToSubject();
113 $this->subject
114 ->expects($this->once())
115 ->method('initializeStandaloneViewInstance');
116 $this->subject->render([]);
117 }
118
119 /**
120 * @test
121 */
122 public function renderCallsTemplateServiceGetFileNameForGivenTemplateFile()
123 {
124 $this->addMockViewToSubject();
125 /** @var $templateService \PHPUnit_Framework_MockObject_MockObject */
126 $templateService = $GLOBALS['TSFE']->tmpl;
127 $templateService
128 ->expects($this->any())
129 ->method('getFileName')
130 ->with('foo');
131 $this->subject->render(['file' => 'foo']);
132 }
133
134 /**
135 * @test
136 */
137 public function renderCallsStandardWrapForGivenTemplateFileWithStandardWrap()
138 {
139 $this->addMockViewToSubject();
140 $this->contentObjectRenderer
141 ->expects($this->any())
142 ->method('stdWrap')
143 ->with('foo', ['bar' => 'baz']);
144 $this->subject->render(['file' => 'foo', 'file.' => ['bar' => 'baz']]);
145 }
146
147 /**
148 * @test
149 */
150 public function renderCallsStandardWrapForGivenTemplateRootPathsWithStandardWrap()
151 {
152 $this->addMockViewToSubject();
153 $this->contentObjectRenderer
154 ->expects($this->at(0))
155 ->method('stdWrap')
156 ->with('dummyPath', ['wrap' => '|5/']);
157 $this->contentObjectRenderer
158 ->expects($this->at(1))
159 ->method('stdWrap')
160 ->with('', ['field' => 'someField']);
161 $this->subject->render(
162 [
163 'templateName' => 'foobar',
164 'templateRootPaths.' => [
165 10 => 'dummyPath',
166 '10.' => [
167 'wrap' => '|5/',
168 ],
169 15 => 'dummyPath6/',
170 '25.' => [
171 'field' => 'someField',
172 ],
173 ]
174 ]
175 );
176 }
177
178 /**
179 * @test
180 */
181 public function renderSetsTemplateFileInView()
182 {
183 $this->addMockViewToSubject();
184 /** @var $templateService \PHPUnit_Framework_MockObject_MockObject */
185 $templateService = $GLOBALS['TSFE']->tmpl;
186 $templateService
187 ->expects($this->any())
188 ->method('getFileName')
189 ->with('foo')
190 ->will($this->returnValue('bar'));
191 $this->standaloneView
192 ->expects($this->any())
193 ->method('setTemplatePathAndFilename')
194 ->with(PATH_site . 'bar');
195 $this->subject->render(['file' => 'foo']);
196 }
197
198 /**
199 * @test
200 */
201 public function renderSetsTemplateFileByTemplateInView()
202 {
203 $this->addMockViewToSubject();
204
205 $this->contentObjectRenderer
206 ->expects($this->any())
207 ->method('cObjGetSingle')
208 ->with('FILE', ['file' => PATH_site . 'foo/bar.html'])
209 ->will($this->returnValue('baz'));
210
211 $this->standaloneView
212 ->expects($this->any())
213 ->method('setTemplateSource')
214 ->with('baz');
215
216 $this->subject->render([
217 'template' => 'FILE',
218 'template.' => [
219 'file' => PATH_site . 'foo/bar.html'
220 ]
221 ]);
222 }
223
224 /**
225 * @test
226 */
227 public function renderSetsTemplateFileByTemplateNameInView()
228 {
229 $this->addMockViewToSubject();
230
231 $this->standaloneView
232 ->expects($this->any())
233 ->method('getFormat')
234 ->will($this->returnValue('html'));
235 $this->standaloneView
236 ->expects($this->once())
237 ->method('setTemplate')
238 ->with('foo');
239
240 $this->subject->render(
241 [
242 'templateName' => 'foo',
243 'templateRootPaths.' => [
244 0 => 'dummyPath1/',
245 1 => 'dummyPath2/']
246 ]
247 );
248 }
249
250 /**
251 * @test
252 */
253 public function renderSetsTemplateFileByTemplateNameStdWrapInView()
254 {
255 $this->addMockViewToSubject();
256
257 $this->contentObjectRenderer
258 ->expects($this->once())
259 ->method('stdWrap')
260 ->with('TEXT', ['value' => 'bar'])
261 ->will($this->returnValue('bar'));
262 $this->standaloneView
263 ->expects($this->any())
264 ->method('getFormat')
265 ->will($this->returnValue('html'));
266 $this->standaloneView
267 ->expects($this->once())
268 ->method('setTemplate')
269 ->with('bar');
270
271 $this->subject->render(
272 [
273 'templateName' => 'TEXT',
274 'templateName.' => ['value' => 'bar'],
275 'templateRootPaths.' => [
276 0 => 'dummyPath1/',
277 1 => 'dummyPath2/']
278 ]
279 );
280 }
281
282 /**
283 * @test
284 */
285 public function renderSetsLayoutRootPathInView()
286 {
287 $this->addMockViewToSubject();
288 $this->standaloneView
289 ->expects($this->once())
290 ->method('setLayoutRootPaths')
291 ->with([PATH_site . 'foo/bar.html']);
292 $this->subject->render(['layoutRootPath' => 'foo/bar.html']);
293 }
294
295 /**
296 * @test
297 */
298 public function renderCallsStandardWrapForLayoutRootPath()
299 {
300 $this->addMockViewToSubject();
301 $this->contentObjectRenderer
302 ->expects($this->once())
303 ->method('stdWrap')
304 ->with('foo', ['bar' => 'baz']);
305 $this->subject->render(['layoutRootPath' => 'foo', 'layoutRootPath.' => ['bar' => 'baz']]);
306 }
307
308 /**
309 * @test
310 */
311 public function layoutRootPathsHasStdWrapSupport()
312 {
313 $this->addMockViewToSubject();
314 $this->contentObjectRenderer
315 ->expects($this->at(0))
316 ->method('stdWrap')
317 ->with('FILE', ['file' => 'foo/bar.html']);
318 $this->subject->render(
319 [
320 'layoutRootPaths.' => [
321 10 => 'FILE',
322 '10.' => [
323 'file' => 'foo/bar.html',
324 ],
325 20 => 'foo/bar2.html',
326 ]
327 ]
328 );
329 }
330
331 /**
332 * @test
333 */
334 public function fallbacksForLayoutRootPathAreSet()
335 {
336 $this->addMockViewToSubject();
337 $this->standaloneView
338 ->expects($this->once())
339 ->method('setLayoutRootPaths')
340 ->with([10 => PATH_site . 'foo/bar.html', 20 => PATH_site . 'foo/bar2.html']);
341 $this->subject->render(['layoutRootPaths.' => [10 => 'foo/bar.html', 20 => 'foo/bar2.html']]);
342 }
343
344 /**
345 * @test
346 */
347 public function fallbacksForLayoutRootPathAreAppendedToLayoutRootPath()
348 {
349 $this->addMockViewToSubject();
350 $this->standaloneView
351 ->expects($this->once())
352 ->method('setLayoutRootPaths')
353 ->with([0 => PATH_site . 'foo/main.html', 10 => PATH_site . 'foo/bar.html', 20 => PATH_site . 'foo/bar2.html']);
354 $this->subject->render(['layoutRootPath' => 'foo/main.html', 'layoutRootPaths.' => [10 => 'foo/bar.html', 20 => 'foo/bar2.html']]);
355 }
356
357 /**
358 * @test
359 */
360 public function renderSetsPartialRootPathInView()
361 {
362 $this->addMockViewToSubject();
363 $this->standaloneView
364 ->expects($this->once())
365 ->method('setPartialRootPaths')
366 ->with([PATH_site . 'foo/bar.html']);
367 $this->subject->render(['partialRootPath' => 'foo/bar.html']);
368 }
369
370 /**
371 * @test
372 */
373 public function partialRootPathsHasStdWrapSupport()
374 {
375 $this->addMockViewToSubject();
376 $this->contentObjectRenderer
377 ->expects($this->at(0))
378 ->method('stdWrap')
379 ->with('FILE', ['file' => 'foo/bar.html']);
380 $this->subject->render(
381 [
382 'partialRootPaths.' => [
383 10 => 'FILE',
384 '10.' => [
385 'file' => 'foo/bar.html',
386 ],
387 20 => 'foo/bar2.html',
388 ]
389 ]
390 );
391 }
392
393 /**
394 * @test
395 */
396 public function renderCallsStandardWrapForPartialRootPath()
397 {
398 $this->addMockViewToSubject();
399 $this->contentObjectRenderer
400 ->expects($this->once())
401 ->method('stdWrap')
402 ->with('foo', ['bar' => 'baz']);
403 $this->subject->render(['partialRootPath' => 'foo', 'partialRootPath.' => ['bar' => 'baz']]);
404 }
405
406 /**
407 * @test
408 */
409 public function fallbacksForPartialRootPathAreSet()
410 {
411 $this->addMockViewToSubject();
412 $this->standaloneView
413 ->expects($this->once())
414 ->method('setPartialRootPaths')
415 ->with([10 => PATH_site . 'foo', 20 => PATH_site . 'bar']);
416 $this->subject->render(['partialRootPaths.' => [10 => 'foo', 20 => 'bar']]);
417 }
418
419 /**
420 * @test
421 */
422 public function fallbacksForPartialRootPathAreAppendedToPartialRootPath()
423 {
424 $this->addMockViewToSubject();
425 $this->standaloneView
426 ->expects($this->once())
427 ->method('setPartialRootPaths')
428 ->with([0 => PATH_site . 'main', 10 => PATH_site . 'foo', 20 => PATH_site . 'bar']);
429 $this->subject->render(['partialRootPath' => 'main', 'partialRootPaths.' => [10 => 'foo', 20 => 'bar']]);
430 }
431
432 /**
433 * @test
434 */
435 public function renderSetsFormatInView()
436 {
437 $this->addMockViewToSubject();
438 $this->standaloneView
439 ->expects($this->once())
440 ->method('setFormat')
441 ->with('xml');
442 $this->subject->render(['format' => 'xml']);
443 }
444
445 /**
446 * @test
447 */
448 public function renderCallsStandardWrapForFormat()
449 {
450 $this->addMockViewToSubject();
451 $this->contentObjectRenderer
452 ->expects($this->once())
453 ->method('stdWrap')
454 ->with('foo', ['bar' => 'baz']);
455 $this->subject->render(['format' => 'foo', 'format.' => ['bar' => 'baz']]);
456 }
457
458 /**
459 * @test
460 */
461 public function renderSetsExtbasePluginNameInRequest()
462 {
463 $this->addMockViewToSubject();
464 $this->request
465 ->expects($this->once())
466 ->method('setPluginName')
467 ->with('foo');
468 $configuration = [
469 'extbase.' => [
470 'pluginName' => 'foo',
471 ],
472 ];
473 $this->subject->render($configuration);
474 }
475
476 /**
477 * @test
478 */
479 public function renderCallsStandardWrapForExtbasePluginName()
480 {
481 $this->addMockViewToSubject();
482 $this->contentObjectRenderer
483 ->expects($this->once())
484 ->method('stdWrap')
485 ->with('foo', ['bar' => 'baz']);
486 $configuration = [
487 'extbase.' => [
488 'pluginName' => 'foo',
489 'pluginName.' => [
490 'bar' => 'baz',
491 ],
492 ],
493 ];
494 $this->subject->render($configuration);
495 }
496
497 /**
498 * @test
499 */
500 public function renderSetsExtbaseControllerExtensionNameInRequest()
501 {
502 $this->addMockViewToSubject();
503 $this->request
504 ->expects($this->once())
505 ->method('setControllerExtensionName')
506 ->with('foo');
507 $configuration = [
508 'extbase.' => [
509 'controllerExtensionName' => 'foo',
510 ],
511 ];
512 $this->subject->render($configuration);
513 }
514
515 /**
516 * @test
517 */
518 public function renderCallsStandardWrapForExtbaseControllerExtensionName()
519 {
520 $this->addMockViewToSubject();
521 $this->contentObjectRenderer
522 ->expects($this->once())
523 ->method('stdWrap')
524 ->with('foo', ['bar' => 'baz']);
525 $configuration = [
526 'extbase.' => [
527 'controllerExtensionName' => 'foo',
528 'controllerExtensionName.' => [
529 'bar' => 'baz',
530 ],
531 ],
532 ];
533 $this->subject->render($configuration);
534 }
535
536 /**
537 * @test
538 */
539 public function renderSetsExtbaseControllerNameInRequest()
540 {
541 $this->addMockViewToSubject();
542 $this->request
543 ->expects($this->once())
544 ->method('setControllerName')
545 ->with('foo');
546 $configuration = [
547 'extbase.' => [
548 'controllerName' => 'foo',
549 ],
550 ];
551 $this->subject->render($configuration);
552 }
553
554 /**
555 * @test
556 */
557 public function renderCallsStandardWrapForExtbaseControllerName()
558 {
559 $this->addMockViewToSubject();
560 $this->contentObjectRenderer
561 ->expects($this->once())
562 ->method('stdWrap')
563 ->with('foo', ['bar' => 'baz']);
564 $configuration = [
565 'extbase.' => [
566 'controllerName' => 'foo',
567 'controllerName.' => [
568 'bar' => 'baz',
569 ],
570 ],
571 ];
572 $this->subject->render($configuration);
573 }
574
575 /**
576 * @test
577 */
578 public function renderSetsExtbaseControllerActionNameInRequest()
579 {
580 $this->addMockViewToSubject();
581 $this->request
582 ->expects($this->once())
583 ->method('setControllerActionName')
584 ->with('foo');
585 $configuration = [
586 'extbase.' => [
587 'controllerActionName' => 'foo',
588 ],
589 ];
590 $this->subject->render($configuration);
591 }
592
593 /**
594 * @test
595 */
596 public function renderCallsStandardWrapForExtbaseControllerActionName()
597 {
598 $this->addMockViewToSubject();
599 $this->contentObjectRenderer
600 ->expects($this->once())
601 ->method('stdWrap')
602 ->with('foo', ['bar' => 'baz']);
603 $configuration = [
604 'extbase.' => [
605 'controllerActionName' => 'foo',
606 'controllerActionName.' => [
607 'bar' => 'baz',
608 ],
609 ],
610 ];
611 $this->subject->render($configuration);
612 }
613
614 /**
615 * @test
616 */
617 public function renderAssignsSettingsArrayToView()
618 {
619 $this->addMockViewToSubject();
620
621 $configuration = [
622 'settings.' => [
623 'foo' => 'value',
624 'bar.' => [
625 'baz' => 'value2',
626 ],
627 ],
628 ];
629
630 $expectedSettingsToBeSet = [
631 'foo' => 'value',
632 'bar' => [
633 'baz' => 'value2',
634 ],
635 ];
636
637 /** @var TypoScriptService|\PHPUnit_Framework_MockObject_MockObject $typoScriptServiceMock */
638 $typoScriptServiceMock = $this->getMockBuilder(TypoScriptService::class)->getMock();
639 $typoScriptServiceMock
640 ->expects($this->once())
641 ->method('convertTypoScriptArrayToPlainArray')
642 ->with($configuration['settings.'])
643 ->will($this->returnValue($expectedSettingsToBeSet));
644 GeneralUtility::addInstance(TypoScriptService::class, $typoScriptServiceMock);
645
646 $this->standaloneView
647 ->expects($this->at(1))
648 ->method('assign')
649 ->with('settings', $expectedSettingsToBeSet);
650
651 $this->subject->render($configuration);
652 }
653
654 /**
655 * @test
656 */
657 public function renderThrowsExceptionForNotAllowedVariableData()
658 {
659 $this->addMockViewToSubject();
660 $configuration = [
661 'variables.' => [
662 'data' => 'foo',
663 'data.' => [
664 'bar' => 'baz',
665 ],
666 ],
667 ];
668 $this->expectException(\InvalidArgumentException::class);
669 $this->expectExceptionCode(1288095720);
670 $this->subject->render($configuration);
671 }
672
673 /**
674 * @test
675 */
676 public function renderThrowsExceptionForNotAllowedVariableCurrent()
677 {
678 $this->addMockViewToSubject();
679 $configuration = [
680 'variables.' => [
681 'current' => 'foo',
682 'current.' => [
683 'bar' => 'baz',
684 ],
685 ],
686 ];
687 $this->expectException(\InvalidArgumentException::class);
688 $this->expectExceptionCode(1288095720);
689 $this->subject->render($configuration);
690 }
691
692 /**
693 * @test
694 */
695 public function renderCallsCObjGetSingleForAllowedVariable()
696 {
697 $this->addMockViewToSubject();
698 $configuration = [
699 'variables.' => [
700 'aVar' => 'TEXT',
701 'aVar.' => [
702 'value' => 'foo',
703 ],
704 ],
705 ];
706 $this->contentObjectRenderer
707 ->expects($this->once())
708 ->method('cObjGetSingle')
709 ->with('TEXT', ['value' => 'foo']);
710 $this->subject->render($configuration);
711 }
712
713 /**
714 * @test
715 */
716 public function renderAssignsRenderedContentObjectVariableToView()
717 {
718 $this->addMockViewToSubject();
719 $configuration = [
720 'variables.' => [
721 'aVar' => 'TEXT',
722 'aVar.' => [
723 'value' => 'foo',
724 ],
725 ],
726 ];
727 $this->contentObjectRenderer
728 ->expects($this->once())
729 ->method('cObjGetSingle')
730 ->will($this->returnValue('foo'));
731 $this->standaloneView
732 ->expects($this->once())
733 ->method('assignMultiple')
734 ->with(['aVar' => 'foo', 'data' => [], 'current' => null]);
735 $this->subject->render($configuration);
736 }
737
738 /**
739 * @test
740 */
741 public function renderAssignsContentObjectRendererDataToView()
742 {
743 $this->addMockViewToSubject();
744 $this->contentObjectRenderer->data = ['foo'];
745 $this->standaloneView
746 ->expects($this->once())
747 ->method('assignMultiple')
748 ->with(['data' => ['foo'], 'current' => null]);
749 $this->subject->render([]);
750 }
751
752 /**
753 * @test
754 */
755 public function renderAssignsContentObjectRendererCurrentValueToView()
756 {
757 $this->addMockViewToSubject();
758 $this->contentObjectRenderer->data = ['currentKey' => 'currentValue'];
759 $this->contentObjectRenderer->currentValKey = 'currentKey';
760 $this->standaloneView
761 ->expects($this->once())
762 ->method('assignMultiple')
763 ->with(['data' => ['currentKey' => 'currentValue'], 'current' => 'currentValue']);
764 $this->subject->render([]);
765 }
766
767 /**
768 * @test
769 */
770 public function renderCallsRenderOnStandaloneViewie()
771 {
772 $this->addMockViewToSubject();
773 $this->standaloneView
774 ->expects($this->once())
775 ->method('render');
776 $this->subject->render([]);
777 }
778
779 /**
780 * @test
781 */
782 public function renderCallsStandardWrapOnResultStringIfGivenInConfiguration()
783 {
784 $this->addMockViewToSubject();
785 $configuration = [
786 'stdWrap.' => [
787 'foo' => 'bar',
788 ],
789 ];
790 $this->standaloneView
791 ->expects($this->any())
792 ->method('render')
793 ->will($this->returnValue('baz'));
794 $this->contentObjectRenderer
795 ->expects($this->once())
796 ->method('stdWrap')
797 ->with('baz', ['foo' => 'bar']);
798 $this->subject->render($configuration);
799 }
800
801 /**
802 * @param TemplateView $viewMock
803 * @param string|null $expectedHeader
804 * @param string|null $expectedFooter
805 * @test
806 * @dataProvider headerAssetDataProvider
807 */
808 public function renderFluidTemplateAssetsIntoPageRendererRendersAndAttachesAssets($viewMock, $expectedHeader, $expectedFooter)
809 {
810 $pageRendererMock = $this->getMockBuilder(PageRenderer::class)->setMethods(['addHeaderData', 'addFooterData'])->getMock();
811 if (!empty(trim($expectedHeader))) {
812 $pageRendererMock->expects($this->once())->method('addHeaderData')->with($expectedHeader);
813 } else {
814 $pageRendererMock->expects($this->never())->method('addHeaderData');
815 }
816 if (!empty(trim($expectedFooter))) {
817 $pageRendererMock->expects($this->once())->method('addFooterData')->with($expectedFooter);
818 } else {
819 $pageRendererMock->expects($this->never())->method('addFooterData');
820 }
821 $subject = $this->getMockBuilder(FluidTemplateContentObject::class)->setMethods(['getPageRenderer'])->disableOriginalConstructor()->getMock();
822 $subject->expects($this->once())->method('getPageRenderer')->willReturn($pageRendererMock);
823 $viewProperty = new \ReflectionProperty($subject, 'view');
824 $viewProperty->setAccessible(true);
825 $viewProperty->setValue($subject, $viewMock);
826
827 $method = new \ReflectionMethod($subject, 'renderFluidTemplateAssetsIntoPageRenderer');
828 $method->setAccessible(true);
829 $method->invoke($subject);
830 }
831
832 /**
833 * @return array
834 */
835 public function headerAssetDataProvider()
836 {
837 $viewWithHeaderData = $this->getMockBuilder(TemplateView::class)->setMethods(['renderSection'])->disableOriginalConstructor()->getMock();
838 $viewWithHeaderData->expects($this->at(0))->method('renderSection')->with('HeaderAssets', $this->anything(), true)->willReturn('custom-header-data');
839 $viewWithHeaderData->expects($this->at(1))->method('renderSection')->with('FooterAssets', $this->anything(), true)->willReturn(null);
840 $viewWithFooterData = $this->getMockBuilder(TemplateView::class)->setMethods(['renderSection'])->disableOriginalConstructor()->getMock();
841 $viewWithFooterData->expects($this->at(0))->method('renderSection')->with('HeaderAssets', $this->anything(), true)->willReturn(null);
842 $viewWithFooterData->expects($this->at(1))->method('renderSection')->with('FooterAssets', $this->anything(), true)->willReturn('custom-footer-data');
843 $viewWithBothData = $this->getMockBuilder(TemplateView::class)->setMethods(['renderSection'])->disableOriginalConstructor()->getMock();
844 $viewWithBothData->expects($this->at(0))->method('renderSection')->with('HeaderAssets', $this->anything(), true)->willReturn('custom-header-data');
845 $viewWithBothData->expects($this->at(1))->method('renderSection')->with('FooterAssets', $this->anything(), true)->willReturn('custom-footer-data');
846 return [
847 [$viewWithHeaderData, 'custom-header-data', null],
848 [$viewWithFooterData, null, 'custom-footer-data'],
849 [$viewWithBothData, 'custom-header-data', 'custom-footer-data']
850 ];
851 }
852 }