‪TYPO3CMS  9.5
TcaDatabaseRecordTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪TcaDatabaseRecordTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
35  protected function ‪setUp()
36  {
37  $this->subject = new ‪TcaDatabaseRecord();
38  }
39 
43  public function ‪compileReturnsIncomingData()
44  {
46  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
47  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
48  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
49 
50  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'] = [];
51 
52  $input = ['foo'];
53 
54  $this->assertEquals($input, $this->subject->compile($input));
55  }
56 
61  {
63  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
64  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
65  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
66 
68  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
69  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'] = [
70  FormDataProviderInterface::class => [],
71  ];
72  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
73  $providerResult = ['foo'];
74  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
75 
76  $this->assertEquals($providerResult, $this->subject->compile([]));
77  }
78 
83  {
85  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
86  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
87  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
88 
90  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
91  ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'] = [
92  \stdClass::class => [],
93  ];
94  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
95 
96  $this->expectException(\UnexpectedValueException::class);
97  $this->expectExceptionCode(1485299408);
98 
99  $this->subject->compile([]);
100  }
101 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\TcaDatabaseRecordTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: TcaDatabaseRecordTest.php:42
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\TcaDatabaseRecordTest\setUp
‪setUp()
Definition: TcaDatabaseRecordTest.php:34
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\TcaDatabaseRecordTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: TcaDatabaseRecordTest.php:59
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\TcaDatabaseRecordTest
Definition: TcaDatabaseRecordTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\TcaDatabaseRecordTest\$subject
‪TcaDatabaseRecord $subject
Definition: TcaDatabaseRecordTest.php:32
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\TcaDatabaseRecordTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: TcaDatabaseRecordTest.php:81
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:22
‪$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\TcaDatabaseRecord
Definition: TcaDatabaseRecord.php:24