TYPO3 CMS  TYPO3_7-6
FlexFormSegmentTest.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 
24 
29 {
33  protected $subject;
34 
35  protected function setUp()
36  {
37  $this->subject = new FlexFormSegment();
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']['flexFormSegment'] = [];
51 
52  $input = ['foo'];
53 
54  $this->assertEquals($input, $this->subject->compile($input));
55  }
56 
60  public function compileReturnsResultChangedByDataProvider()
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']['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  $this->assertEquals($providerResult, $this->subject->compile([]));
77  }
78 
82  public function compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
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']['flexFormSegment'] = [
92  \stdClass::class => [],
93  ];
94  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
95 
96  $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1437906441);
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']