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