‪TYPO3CMS  11.5
ExtendedTemplateServiceTest.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\MockObject\MockObject;
21 use TYPO3\CMS\Core\TypoScript\ExtendedTemplateService;
22 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪ExtendedTemplateServiceTest extends UnitTestCase
29 {
34 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->extendedTemplateServiceMock = $this->getAccessibleMock(
42  ExtendedTemplateService::class,
43  null,
44  [],
45  '',
46  false
47  );
48  }
49 
54  public function ‪ext_getSetupTest($setup, $key, $expected): void
55  {
56  $actual = $this->extendedTemplateServiceMock->ext_getSetup($setup, $key);
57  self::assertEquals($expected, $actual);
58  }
59 
60  public function ‪ext_getSetupDataProvider(): array
61  {
62  return [
63  'empty setup and key' => [
64  [],
65  '',
66  [[], ''],
67  ],
68  'empty setup and not empty key' => [
69  [],
70  'key',
71  [[], ''],
72  ],
73  'empty key' => [
74  'typoScriptSetup' => [
75  '10.' => [
76  'value' => 'Hello World!',
77  'foo.' => [
78  'bar' => 5,
79  ],
80  ],
81  '10' => 'TEXT',
82  ],
83  'key' => '',
84  'expected' => [
85  [
86  '10.' => [
87  'value' => 'Hello World!',
88  'foo.' => [
89  'bar' => 5,
90  ],
91  ],
92  '10' => 'TEXT',
93  ],
94  '',
95  ],
96  ],
97  'special key "0" which is considered as empty' => [
98  'typoScriptSetup' => [
99  '10.' => [
100  'value' => 'Hello World!',
101  'foo.' => [
102  'bar' => 5,
103  ],
104  ],
105  '10' => 'TEXT',
106  ],
107  'key' => '0',
108  'expected' => [
109  [
110  '10.' => [
111  'value' => 'Hello World!',
112  'foo.' => [
113  'bar' => 5,
114  ],
115  ],
116  '10' => 'TEXT',
117  ],
118  '',
119  ],
120  ],
121  'not empty key - 1st level' => [
122  'typoScriptSetup' => [
123  '10.' => [
124  'value' => 'Hello World!',
125  'foo.' => [
126  'bar' => 5,
127  ],
128  ],
129  '10' => 'TEXT',
130  ],
131  'key' => '10',
132  'expected' => [
133  [
134  'value' => 'Hello World!',
135  'foo.' => [
136  'bar' => 5,
137  ],
138  ],
139  'TEXT',
140  ],
141  ],
142  'not empty key - 2nd level' => [
143  'typoScriptSetup' => [
144  '10.' => [
145  'value' => 'Hello World!',
146  'foo.' => [
147  'bar' => 5,
148  ],
149  ],
150  '10' => 'TEXT',
151  ],
152  'key' => '10.foo',
153  'expected' => [
154  [
155  'bar' => 5,
156  ],
157  '',
158  ],
159  ],
160  'not empty key - 3rd level - leaf' => [
161  'typoScriptSetup' => [
162  '10.' => [
163  'value' => 'Hello World!',
164  'foo.' => [
165  'bar' => 5,
166  ],
167  ],
168  '10' => 'TEXT',
169  ],
170  'key' => '10.foo.bar',
171  'expected' => [
172  [],
173  '5',
174  ],
175  ],
176  'not empty key - 4th, non existing level' => [
177  'typoScriptSetup' => [
178  '10.' => [
179  'value' => 'Hello World!',
180  'foo.' => [
181  'bar' => 5,
182  ],
183  ],
184  '10' => 'TEXT',
185  ],
186  'key' => '10.foo.bar.baz',
187  'expected' => [
188  [],
189  '',
190  ],
191  ],
192  ];
193  }
194 }
‪TYPO3\CMS\Core\Tests\Unit\TypoScript
Definition: ExtendedTemplateServiceTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\ExtendedTemplateServiceTest
Definition: ExtendedTemplateServiceTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\ExtendedTemplateServiceTest\setUp
‪setUp()
Definition: ExtendedTemplateServiceTest.php:37
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\ExtendedTemplateServiceTest\$extendedTemplateServiceMock
‪ExtendedTemplateService MockObject AccessibleObjectInterface $extendedTemplateServiceMock
Definition: ExtendedTemplateServiceTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\ExtendedTemplateServiceTest\ext_getSetupDataProvider
‪ext_getSetupDataProvider()
Definition: ExtendedTemplateServiceTest.php:59
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\ExtendedTemplateServiceTest\ext_getSetupTest
‪ext_getSetupTest($setup, $key, $expected)
Definition: ExtendedTemplateServiceTest.php:53