TYPO3 CMS  TYPO3_8-7
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 
23 
27 class TcaDatabaseRecordTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
32  protected $subject;
33 
34  protected function setUp()
35  {
36  $this->subject = new TcaDatabaseRecord();
37  }
38 
42  public function compileReturnsIncomingData()
43  {
45  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
46  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
47  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
48 
49  $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'] = [];
50 
51  $input = ['foo'];
52 
53  $this->assertEquals($input, $this->subject->compile($input));
54  }
55 
59  public function compileReturnsResultChangedByDataProvider()
60  {
62  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
63  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
64  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
65 
67  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
68  $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'] = [
69  FormDataProviderInterface::class => [],
70  ];
71  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
72  $providerResult = ['foo'];
73  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
74 
75  $this->assertEquals($providerResult, $this->subject->compile([]));
76  }
77 
81  public function compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
82  {
84  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
85  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
86  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
87 
89  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
90  $GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['formDataGroup']['tcaDatabaseRecord'] = [
91  \stdClass::class => [],
92  ];
93  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
94 
95  $this->expectException(\UnexpectedValueException::class);
96  $this->expectExceptionCode(1485299408);
97 
98  $this->subject->compile([]);
99  }
100 }
static addInstance($className, $instance)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']