‪TYPO3CMS  11.5
FlexFormSegmentTest.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\PhpUnit\ProphecyTrait;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪FlexFormSegmentTest extends UnitTestCase
32 {
33  use ProphecyTrait;
34 
36 
37  protected function ‪setUp(): void
38  {
39  parent::setUp();
40  $this->subject = new ‪FlexFormSegment();
41  }
42 
46  public function ‪compileReturnsIncomingData(): void
47  {
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']['flexFormSegment'] = [];
53 
54  $input = ['foo'];
55 
56  self::assertEquals($input, $this->subject->compile($input));
57  }
58 
62  public function ‪compileReturnsResultChangedByDataProvider(): void
63  {
64  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
65  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
66  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
67 
68  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
69  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['flexFormSegment'] = [
70  FormDataProviderInterface::class => [],
71  ];
72  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
73  $providerResult = ['foo'];
74  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
75 
76  self::assertEquals($providerResult, $this->subject->compile([]));
77  }
78 
83  {
84  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
85  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
86  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
87 
88  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
89  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['flexFormSegment'] = [
90  \stdClass::class => [],
91  ];
92  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
93 
94  $this->expectException(\UnexpectedValueException::class);
95  $this->expectExceptionCode(1485299408);
96 
97  $this->subject->compile([]);
98  }
99 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\FlexFormSegmentTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: FlexFormSegmentTest.php:81
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\FlexFormSegmentTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: FlexFormSegmentTest.php:45
‪TYPO3\CMS\Backend\Form\FormDataGroup\FlexFormSegment
Definition: FlexFormSegment.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\FlexFormSegmentTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: FlexFormSegmentTest.php:61
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\FlexFormSegmentTest\$subject
‪FlexFormSegment $subject
Definition: FlexFormSegmentTest.php:34
‪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\FlexFormSegmentTest\setUp
‪setUp()
Definition: FlexFormSegmentTest.php:36
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup
Definition: FlexFormSegmentTest.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\FlexFormSegmentTest
Definition: FlexFormSegmentTest.php:32