‪TYPO3CMS  10.4
SiteConfigurationDataGroupTest.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 Prophecy\Prophecy\ObjectProphecy;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪SiteConfigurationDataGroupTest extends UnitTestCase
32 {
36  protected ‪$subject;
37 
38  protected function ‪setUp(): void
39  {
40  $this->subject = new ‪SiteConfigurationDataGroup();
41  }
42 
46  public function ‪compileReturnsIncomingData()
47  {
49  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
50  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
51  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
52 
53  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'] = [];
54 
55  $input = ['foo'];
56 
57  self::assertEquals($input, $this->subject->compile($input));
58  }
59 
64  {
66  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
67  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
68  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
69 
71  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
72  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'] = [
73  FormDataProviderInterface::class => [],
74  ];
75  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
76  $providerResult = ['foo'];
77  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
78 
79  self::assertEquals($providerResult, $this->subject->compile([]));
80  }
81 
86  {
88  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
89  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
90  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
91 
93  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
94  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['siteConfiguration'] = [
95  \stdClass::class => [],
96  ];
97  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
98 
99  $this->expectException(\UnexpectedValueException::class);
100  $this->expectExceptionCode(1485299408);
101 
102  $this->subject->compile([]);
103  }
104 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: SiteConfigurationDataGroupTest.php:84
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\setUp
‪setUp()
Definition: SiteConfigurationDataGroupTest.php:37
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest
Definition: SiteConfigurationDataGroupTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\$subject
‪SiteConfigurationDataGroup $subject
Definition: SiteConfigurationDataGroupTest.php:35
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: SiteConfigurationDataGroupTest.php:45
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup
Definition: FlexFormSegmentTest.php:16
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Backend\Form\FormDataGroup\SiteConfigurationDataGroup
Definition: SiteConfigurationDataGroup.php:33
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\SiteConfigurationDataGroupTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: SiteConfigurationDataGroupTest.php:62