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