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