‪TYPO3CMS  9.5
OrderedProviderListTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Prophecy\Argument;
19 use Prophecy\Prophecy\ObjectProphecy;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪OrderedProviderListTest extends UnitTestCase
30 {
35  {
37  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
38  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
39  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
40 
41  $input = ['foo'];
42 
43  $subject = new ‪OrderedProviderList();
44  $subject->setProviderList([]);
45  $this->assertEquals($input, $subject->compile($input));
46  }
47 
52  {
54  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
55  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
56  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
57 
59  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
60  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
61  $providerResult = ['foo'];
62  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
63 
64  $subject = new ‪OrderedProviderList();
65  $subject->setProviderList([
66  FormDataProviderInterface::class => [],
67  ]);
68  $this->assertEquals($providerResult, $subject->compile([]));
69  }
70 
75  {
77  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
78  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
79  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
80 
81  $subject = new ‪OrderedProviderList();
82  $subject->setProviderList([
83  FormDataProviderInterface::class => [
84  'disabled' => true,
85  ],
86  ]);
87  $input = ['foo'];
88  $this->assertEquals($input, $subject->compile($input));
89  }
90 
95  {
97  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
98  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
99  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
100 
102  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
103  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
104 
105  $this->expectException(\UnexpectedValueException::class);
106  $this->expectExceptionCode(1485299408);
107 
108  $subject = new ‪OrderedProviderList();
109  $subject->setProviderList([
110  \stdClass::class => [],
111  ]);
112  $subject->compile([]);
113  }
114 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest
Definition: OrderedProviderListTest.php:30
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: OrderedProviderListTest.php:51
‪TYPO3\CMS\Backend\Form\FormDataGroup\OrderedProviderList
Definition: OrderedProviderList.php:30
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: OrderedProviderListTest.php:94
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: OrderedProviderListTest.php:34
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:22
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup
Definition: FlexFormSegmentTest.php:2
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileDoesNotCallDisabledDataProvider
‪compileDoesNotCallDisabledDataProvider()
Definition: OrderedProviderListTest.php:74