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