‪TYPO3CMS  10.4
ExtensionConfigurationTest.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 Prophecy\Argument;
21 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪ExtensionConfigurationTest extends UnitTestCase
30 {
35  {
36  ‪$extConf = [
37  'aFeature' => 'iAmEnabled',
38  'aFlagCategory' => [
39  'someFlag' => 'foo',
40  ],
41  ];
42  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['someExtension'] = ‪$extConf;
43  self::assertSame((new ‪ExtensionConfiguration())->get('someExtension'), ‪$extConf);
44  }
45 
50  {
51  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['someExtension'] = [
52  'aFeature' => 'iAmEnabled',
53  'aFlagCategory' => [
54  'someFlag' => 'foo',
55  ],
56  ];
57  self::assertSame((new ‪ExtensionConfiguration())->get('someExtension', 'aFeature'), 'iAmEnabled');
58  }
59 
64  {
65  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['someExtension'] = [
66  'aFeature' => 'iAmEnabled',
67  'aFlagCategory' => [
68  'someFlag' => 'foo',
69  ],
70  ];
71  self::assertSame((new ‪ExtensionConfiguration())->get('someExtension', 'aFlagCategory'), ['someFlag' => 'foo']);
72  }
73 
78  {
79  $this->expectException(\RuntimeException::class);
80  $this->expectExceptionCode(1509715852);
81  (new ‪ExtensionConfiguration())->set('');
82  }
83 
88  {
89  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
90  GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerProphecy->reveal());
91  $configurationManagerProphecy->removeLocalConfigurationKeysByPath(['EXTENSIONS/foo'])->shouldBeCalled();
92  (new ‪ExtensionConfiguration())->set('foo');
93  }
94 
99  {
100  $configurationManagerProphecy = $this->prophesize(ConfigurationManager::class);
101  GeneralUtility::addInstance(ConfigurationManager::class, $configurationManagerProphecy->reveal());
102  $configurationManagerProphecy->setLocalConfigurationValueByPath(Argument::cetera())->shouldBeCalled();
103  $configurationManagerProphecy->setLocalConfigurationValueByPath('EXTENSIONS/foo', ['bar' => 'baz'])->shouldBeCalled();
104  (new ‪ExtensionConfiguration())->set('foo', '', ['bar' => 'baz']);
105  }
106 }
‪TYPO3\CMS\Core\Configuration\ExtensionConfiguration
Definition: ExtensionConfiguration.php:45
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest
Definition: ExtensionConfigurationTest.php:30
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest\getWithPathReturnsGivenValue
‪getWithPathReturnsGivenValue()
Definition: ExtensionConfigurationTest.php:49
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest\setThrowsExceptionWithEmptyExtension
‪setThrowsExceptionWithEmptyExtension()
Definition: ExtensionConfigurationTest.php:77
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest\getWithPathReturnsGivenPathSegment
‪getWithPathReturnsGivenPathSegment()
Definition: ExtensionConfigurationTest.php:63
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest\setRemovesFullExtensionConfiguration
‪setRemovesFullExtensionConfiguration()
Definition: ExtensionConfigurationTest.php:87
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest\setWritesFullExtensionConfig
‪setWritesFullExtensionConfig()
Definition: ExtensionConfigurationTest.php:98
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Tests\Unit\Configuration\ExtensionConfigurationTest\getWithEmptyPathReturnsEntireExtensionConfiguration
‪getWithEmptyPathReturnsEntireExtensionConfiguration()
Definition: ExtensionConfigurationTest.php:34
‪$extConf
‪$extConf
Definition: ext_localconf.php:56
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Tests\Unit\Configuration
Definition: ConfigurationManagerTest.php:18