‪TYPO3CMS  ‪main
GlobalVariableProviderTest.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;
21 use Psr\EventDispatcher\EventDispatcherInterface;
22 use Symfony\Component\DependencyInjection\Container;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 
28 final class ‪GlobalVariableProviderTest extends FunctionalTestCase
29 {
30  #[Test]
32  {
33  $modifyBlindedConfigurationOptionsEvent = null;
34 
35  ‪$identifier = 'foo-bar';
36  $globalVariableKey = 'FOOBAR';
37  ‪$GLOBALS[$globalVariableKey] = ['someoption' => 'password123'];
38  $blindedConfiguration = ['someoption' => '***blinded***'];
39  $modifiedBlindedConfigurationOptions = [$globalVariableKey => $blindedConfiguration];
40 
42  $container = $this->get('service_container');
43  $container->set(
44  'modify-blinded-configuration-options',
45  static function (‪ModifyBlindedConfigurationOptionsEvent $event) use (
46  &$modifyBlindedConfigurationOptionsEvent,
47  $modifiedBlindedConfigurationOptions
48  ) {
49  $event->‪setBlindedConfigurationOptions($modifiedBlindedConfigurationOptions);
50  $modifyBlindedConfigurationOptionsEvent = $event;
51  }
52  );
53 
54  $eventListener = $container->get(ListenerProvider::class);
55  $eventListener->addListener(ModifyBlindedConfigurationOptionsEvent::class, 'modify-blinded-configuration-options');
56 
57  $subject = new ‪GlobalVariableProvider($container->get(EventDispatcherInterface::class));
58  $subject([
59  'identifier' => ‪$identifier,
60  'label' => 'bar',
61  'globalVariableKey' => $globalVariableKey,
62  ]);
63  $configuration = $subject->getConfiguration();
64 
65  self::assertInstanceOf(ModifyBlindedConfigurationOptionsEvent::class, $modifyBlindedConfigurationOptionsEvent);
66  self::assertEquals($modifiedBlindedConfigurationOptions, $modifyBlindedConfigurationOptionsEvent->getBlindedConfigurationOptions());
67  self::assertEquals(‪$identifier, $modifyBlindedConfigurationOptionsEvent->getProviderIdentifier());
68  self::assertEquals($blindedConfiguration, $configuration);
69  }
70 }
‪TYPO3\CMS\Lowlevel\Tests\Functional\ConfigurationModuleProvider
Definition: GlobalVariableProviderTest.php:18
‪TYPO3\CMS\Lowlevel\ConfigurationModuleProvider\GlobalVariableProvider
Definition: GlobalVariableProvider.php:25
‪TYPO3\CMS\Lowlevel\Tests\Functional\ConfigurationModuleProvider\GlobalVariableProviderTest
Definition: GlobalVariableProviderTest.php:29
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Lowlevel\Event\ModifyBlindedConfigurationOptionsEvent\setBlindedConfigurationOptions
‪setBlindedConfigurationOptions(array $blindedConfigurationOptions)
Definition: ModifyBlindedConfigurationOptionsEvent.php:34
‪TYPO3\CMS\Core\EventDispatcher\ListenerProvider
Definition: ListenerProvider.php:30
‪TYPO3\CMS\Lowlevel\Tests\Functional\ConfigurationModuleProvider\GlobalVariableProviderTest\modifyBlindedConfigurationOptionsEventIsTriggered
‪modifyBlindedConfigurationOptionsEventIsTriggered()
Definition: GlobalVariableProviderTest.php:31
‪TYPO3\CMS\Lowlevel\Event\ModifyBlindedConfigurationOptionsEvent
Definition: ModifyBlindedConfigurationOptionsEvent.php:25
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37