‪TYPO3CMS  10.4
ConstantConfigurationParserTest.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 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
25 class ‪ConstantConfigurationParserTest extends UnitTestCase
26 {
27  protected ‪$backupEnvironment = true;
28 
33  {
34  $rawConfiguration = '
35 # cat=basic/xxx/011; type=options[de,en,fr,zh]; label= options[de, en, fr, zh] a drop down option field
36 t7 = de
37 
38 # cat=basic/xxx/010; type=boolean; label= enable: a checkbox
39 t8 = 1
40 
41 # cat=basic/xxx/010; type=small; label= small a short input field
42 t9 = xyz';
43 
44  $expected = [
45  't7' => [
46  'cat' => 'basic',
47  'subcat' => 'x/011z',
48  'type' => 'options[de,en,fr,zh]',
49  'label' => 'options[de, en, fr, zh] a drop down option field',
50  'name' => 't7',
51  'value' => 'de',
52  'default_value' => 'de',
53  ],
54  't8' => [
55  'cat' => 'basic',
56  'subcat' => 'x/010z',
57  'type' => 'boolean',
58  'label' => 'enable: a checkbox',
59  'name' => 't8',
60  'value' => '1',
61  'default_value' => '1',
62  ],
63  't9' => [
64  'cat' => 'basic',
65  'subcat' => 'x/010z',
66  'type' => 'small',
67  'label' => 'small a short input field',
68  'name' => 't9',
69  'value' => 'xyz',
70  'default_value' => 'xyz',
71  ],
72  ];
73 
74  $result = (new ‪ConstantConfigurationParser())->getConfigurationAsValuedArray($rawConfiguration);
75  self::assertSame($expected, $result);
76  }
77 
82  {
83  // ensure condition would match if evaluated
85  new ‪ApplicationContext('Development'),
92  ‪Environment::getBackendPath() . '/index.php',
93  ‪Environment::isWindows() ? 'WINDOWS' : 'UNIX'
94  );
95  $rawConfiguration = '
96 # cat=basic/xxx/011; type=options[de,en,fr,zh]; label= options[de, en, fr, zh] a drop down option field
97 t7 = de
98 
99 [applicationContext == "Development"]
100 # cat=basic/xxx/010; type=boolean; label= enable: a checkbox
101 t8 = 1
102 [global]
103 
104 # cat=basic/xxx/010; type=small; label= small a short input field
105 t9 = xyz';
106 
107  $expected = [
108  't7' => [
109  'cat' => 'basic',
110  'subcat' => 'x/011z',
111  'type' => 'options[de,en,fr,zh]',
112  'label' => 'options[de, en, fr, zh] a drop down option field',
113  'name' => 't7',
114  'value' => 'de',
115  'default_value' => 'de',
116  ],
117  't9' => [
118  'cat' => 'basic',
119  'subcat' => 'x/010z',
120  'type' => 'small',
121  'label' => 'small a short input field',
122  'name' => 't9',
123  'value' => 'xyz',
124  'default_value' => 'xyz',
125  ],
126  ];
127 
128  $result = (new ‪ConstantConfigurationParser())->getConfigurationAsValuedArray($rawConfiguration);
129  self::assertSame($expected, $result);
130  }
131 }
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\Parser\ConstantConfigurationParserTest\getConfigurationAsValuedIgnoresConstantsInConditions
‪getConfigurationAsValuedIgnoresConstantsInConditions()
Definition: ConstantConfigurationParserTest.php:81
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\Parser
Definition: ConstantConfigurationParserTest.php:18
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Core\Core\ApplicationContext
Definition: ApplicationContext.php:37
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\Parser\ConstantConfigurationParserTest
Definition: ConstantConfigurationParserTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\Parser\ConstantConfigurationParserTest\$backupEnvironment
‪$backupEnvironment
Definition: ConstantConfigurationParserTest.php:27
‪TYPO3\CMS\Core\Core\Environment\isWindows
‪static bool isWindows()
Definition: Environment.php:292
‪TYPO3\CMS\Core\Tests\Unit\TypoScript\Parser\ConstantConfigurationParserTest\getConfigurationAsValuedArrayReturnsArrayOfConstants
‪getConfigurationAsValuedArrayReturnsArrayOfConstants()
Definition: ConstantConfigurationParserTest.php:32
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:169
‪TYPO3\CMS\Core\Core\Environment\initialize
‪static initialize(ApplicationContext $context, bool $cli, bool $composerMode, string $projectPath, string $publicPath, string $varPath, string $configPath, string $currentScript, string $os)
Definition: Environment.php:104
‪TYPO3\CMS\Core\Core\Environment\getBackendPath
‪static string getBackendPath()
Definition: Environment.php:250
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:144
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\TypoScript\Parser\ConstantConfigurationParser
Definition: ConstantConfigurationParser.php:34
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:210
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192