‪TYPO3CMS  ‪main
BackendViewFactoryTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 final class ‪BackendViewFactoryTest extends FunctionalTestCase
27 {
28  protected array ‪$testExtensionsToLoad = [
29  'typo3/sysext/backend/Tests/Functional/View/Fixtures/Extensions/test_templates_a',
30  'typo3/sysext/backend/Tests/Functional/View/Fixtures/Extensions/test_templates_b',
31  'typo3/sysext/backend/Tests/Functional/View/Fixtures/Extensions/test_templates_c',
32  ];
33 
34  #[Test]
36  {
37  $request = (new ‪ServerRequest())->withAttribute('route', new ‪Route('testing', ['packageName' => 'typo3tests/cms-test-templates-a']));
38  $subject = $this->get(BackendViewFactory::class);
39  $view = $subject->create($request);
40  $result = $view->render('Foo');
41  self::assertStringContainsString('Foo template from extension test_templates_a', $result);
42  self::assertStringContainsString('Foo layout from extension test_templates_a', $result);
43  self::assertStringContainsString('Foo partial from extension test_templates_a', $result);
44  }
45 
46  #[Test]
48  {
49  $request = (new ‪ServerRequest())->withAttribute('route', new ‪Route('testing', []));
50  $subject = $this->get(BackendViewFactory::class);
51  $view = $subject->create($request, ['typo3tests/cms-test-templates-a']);
52  $result = $view->render('Foo');
53  self::assertStringContainsString('Foo template from extension test_templates_a', $result);
54  self::assertStringContainsString('Foo layout from extension test_templates_a', $result);
55  self::assertStringContainsString('Foo partial from extension test_templates_a', $result);
56  }
57 
58  #[Test]
60  {
61  $request = (new ‪ServerRequest())->withAttribute('route', new ‪Route('testing', ['packageName' => 'typo3tests/cms-test-templates-a']));
62  $subject = $this->get(BackendViewFactory::class);
63  $view = $subject->create($request, ['typo3tests/cms-test-templates-b']);
64  $result = $view->render('Foo');
65  self::assertStringContainsString('Foo template from extension test_templates_b', $result);
66  self::assertStringContainsString('Foo layout from extension test_templates_b', $result);
67  self::assertStringContainsString('Foo partial from extension test_templates_b', $result);
68  }
69 
70  #[Test]
72  {
73  $request = (new ‪ServerRequest())->withAttribute('route', new ‪Route('testing', []));
74  $subject = $this->get(BackendViewFactory::class);
75  $view = $subject->create(
76  $request,
77  [
78  'typo3tests/cms-test-templates-a',
79  'typo3tests/cms-test-templates-b',
80  ]
81  );
82  $result = $view->render('Foo');
83  self::assertStringContainsString('Foo template from extension test_templates_b', $result);
84  self::assertStringContainsString('Foo layout from extension test_templates_b', $result);
85  self::assertStringContainsString('Foo partial from extension test_templates_b', $result);
86  }
87 
88  #[Test]
90  {
91  $request = (new ‪ServerRequest())->withAttribute('route', new ‪Route('testing', []));
92  $subject = $this->get(BackendViewFactory::class);
93  $view = $subject->create(
94  $request,
95  [
96  'typo3tests/cms-test-templates-b',
97  'typo3tests/cms-test-templates-a',
98  ]
99  );
100  $result = $view->render('Foo');
101  self::assertStringContainsString('Foo template from extension test_templates_a', $result);
102  self::assertStringContainsString('Foo layout from extension test_templates_a', $result);
103  self::assertStringContainsString('Foo partial from extension test_templates_a', $result);
104  }
105 
106  #[Test]
108  {
109  $request = (new ‪ServerRequest())->withAttribute('route', new ‪Route('testing', []));
110  $subject = $this->get(BackendViewFactory::class);
111  $view = $subject->create(
112  $request,
113  [
114  'typo3tests/cms-test-templates-b',
115  'typo3tests/cms-test-templates-a',
116  'typo3tests/cms-test-templates-c',
117  ]
118  );
119  $result = $view->render('Foo');
120  self::assertStringContainsString('Foo template from extension test_templates_a', $result);
121  self::assertStringContainsString('Foo layout from extension test_templates_a', $result);
122  self::assertStringContainsString('Foo partial from extension test_templates_a', $result);
123  }
124 
125  #[Test]
127  {
128  $this->importCSVDataSet(__DIR__ . '/Fixtures/BackendViewFactoryTestPages.csv');
129  $request = (new ‪ServerRequest())
130  ->withAttribute('route', new ‪Route('testing', ['packageName' => 'typo3tests/cms-test-templates-a']))
131  ->withQueryParams(['id' => 1]);
132  $subject = $this->get(BackendViewFactory::class);
133  $view = $subject->create($request);
134  $result = $view->render('Foo');
135  self::assertStringContainsString('Foo template from extension test_templates_b', $result);
136  self::assertStringContainsString('Foo layout from extension test_templates_b', $result);
137  self::assertStringContainsString('Foo partial from extension test_templates_b', $result);
138  }
139 
140  #[Test]
142  {
143  $this->importCSVDataSet(__DIR__ . '/Fixtures/BackendViewFactoryTestPagesWithFallback.csv');
144  $request = (new ‪ServerRequest())
145  ->withAttribute('route', new ‪Route('testing', ['packageName' => 'typo3tests/cms-test-templates-a']))
146  ->withQueryParams(['id' => 1]);
147  $subject = $this->get(BackendViewFactory::class);
148  $view = $subject->create($request);
149  $result = $view->render('Foo');
150  self::assertStringContainsString('Foo template from extension test_templates_b', $result);
151  self::assertStringContainsString('Foo layout from extension test_templates_b', $result);
152  self::assertStringContainsString('Foo partial from extension test_templates_b', $result);
153  }
154 }
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createUsesOverrideTemplatePathsWithBasePackageNameFromRoute
‪createUsesOverrideTemplatePathsWithBasePackageNameFromRoute()
Definition: BackendViewFactoryTest.php:59
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createUsesOverrideTemplatePathsWithMultiplePackagesGivenAsArgument
‪createUsesOverrideTemplatePathsWithMultiplePackagesGivenAsArgument()
Definition: BackendViewFactoryTest.php:71
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createUsesTemplatePathsWithPackageGivenAsRouteOption
‪createUsesTemplatePathsWithPackageGivenAsRouteOption()
Definition: BackendViewFactoryTest.php:35
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createUsesTemplatePathsWithPackageGivenAsArgument
‪createUsesTemplatePathsWithPackageGivenAsArgument()
Definition: BackendViewFactoryTest.php:47
‪TYPO3\CMS\Backend\Tests\Functional\View
Definition: BackendLayoutViewTest.php:18
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createAllowsOverridesUsingTsConfig
‪createAllowsOverridesUsingTsConfig()
Definition: BackendViewFactoryTest.php:126
‪TYPO3\CMS\Backend\Routing\Route
Definition: Route.php:24
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createAllowsOverridesUsingTsConfigUsesFirstExistingFilesInChain
‪createAllowsOverridesUsingTsConfigUsesFirstExistingFilesInChain()
Definition: BackendViewFactoryTest.php:141
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: BackendViewFactoryTest.php:28
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createUsesPrefersTemplateFromLastOverrideWithMultiplePackagesGivenAsArgument
‪createUsesPrefersTemplateFromLastOverrideWithMultiplePackagesGivenAsArgument()
Definition: BackendViewFactoryTest.php:89
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:39
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest
Definition: BackendViewFactoryTest.php:27
‪TYPO3\CMS\Backend\Tests\Functional\View\BackendViewFactoryTest\createUsesFirstExistingFilesInChainBeginningFromLastOverrideWithMultiplePackagesGivenAsArgument
‪createUsesFirstExistingFilesInChainBeginningFromLastOverrideWithMultiplePackagesGivenAsArgument()
Definition: BackendViewFactoryTest.php:107