‪TYPO3CMS  9.5
SiteConfigurationDataGroupTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Prophecy\Argument;
20 use Prophecy\Prophecy\ObjectProphecy;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪SiteConfigurationDataGroupTest extends UnitTestCase
31 {
35  protected ‪$subject;
36 
37  protected function ‪setUp(): void
38  {
39  $this->subject = new ‪SiteConfigurationDataGroup();
40  }
41 
45  public function ‪compileReturnsIncomingData()
46  {
48  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
49  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
50  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
51 
52  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'] = [];
53 
54  $input = ['foo'];
55 
56  $this->assertEquals($input, $this->subject->compile($input));
57  }
58 
63  {
65  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
66  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
67  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
68 
70  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
71  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'] = [
72  FormDataProviderInterface::class => [],
73  ];
74  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
75  $providerResult = ['foo'];
76  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
77 
78  $this->assertEquals($providerResult, $this->subject->compile([]));
79  }
80 
85  {
87  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
88  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
89  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
90 
92  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
93  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'] = [
94  \stdClass::class => [],
95  ];
96  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
97 
98  $this->expectException(\UnexpectedValueException::class);
99  $this->expectExceptionCode(1485299408);
100 
101  $this->subject->compile([]);
102  }
103 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: SiteConfigurationDataGroupTest.php:83
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\setUp
‪setUp()
Definition: SiteConfigurationDataGroupTest.php:36
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest
Definition: SiteConfigurationDataGroupTest.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\$subject
‪SiteConfigurationDataGroup $subject
Definition: SiteConfigurationDataGroupTest.php:34
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:31
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:22
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: SiteConfigurationDataGroupTest.php:44
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup
Definition: FlexFormSegmentTest.php:2
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Form\FormDataGroup\SiteConfigurationDataGroup
Definition: SiteConfigurationDataGroup.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: SiteConfigurationDataGroupTest.php:61