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