‪TYPO3CMS  10.4
OrderedProviderListTest.php
Go to the documentation of this file.
1 <?php
2 
3 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 
19 
20 use Prophecy\Argument;
21 use Prophecy\Prophecy\ObjectProphecy;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪OrderedProviderListTest extends UnitTestCase
32 {
37  {
39  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
40  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
41  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
42 
43  $input = ['foo'];
44 
45  $subject = new ‪OrderedProviderList();
46  $subject->setProviderList([]);
47  self::assertEquals($input, $subject->compile($input));
48  }
49 
54  {
56  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
57  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
58  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
59 
61  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
62  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
63  $providerResult = ['foo'];
64  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
65 
66  $subject = new ‪OrderedProviderList();
67  $subject->setProviderList([
68  FormDataProviderInterface::class => [],
69  ]);
70  self::assertEquals($providerResult, $subject->compile([]));
71  }
72 
77  {
79  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
80  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
81  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
82 
83  $subject = new ‪OrderedProviderList();
84  $subject->setProviderList([
85  FormDataProviderInterface::class => [
86  'disabled' => true,
87  ],
88  ]);
89  $input = ['foo'];
90  self::assertEquals($input, $subject->compile($input));
91  }
92 
97  {
99  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
100  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
101  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
102 
104  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
105  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
106 
107  $this->expectException(\UnexpectedValueException::class);
108  $this->expectExceptionCode(1485299408);
109 
110  $subject = new ‪OrderedProviderList();
111  $subject->setProviderList([
112  \stdClass::class => [],
113  ]);
114  $subject->compile([]);
115  }
116 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest
Definition: OrderedProviderListTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: OrderedProviderListTest.php:53
‪TYPO3\CMS\Backend\Form\FormDataGroup\OrderedProviderList
Definition: OrderedProviderList.php:32
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: OrderedProviderListTest.php:96
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: OrderedProviderListTest.php:36
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪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\OrderedProviderListTest\compileDoesNotCallDisabledDataProvider
‪compileDoesNotCallDisabledDataProvider()
Definition: OrderedProviderListTest.php:76