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