‪TYPO3CMS  11.5
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\PhpUnit\ProphecyTrait;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪OrderedProviderListTest extends UnitTestCase
32 {
33  use ProphecyTrait;
34 
38  public function ‪compileReturnsIncomingData(): void
39  {
40  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
41  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
42  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
43 
44  $input = ['foo'];
45 
46  $subject = new ‪OrderedProviderList();
47  $subject->setProviderList([]);
48  self::assertEquals($input, $subject->compile($input));
49  }
50 
54  public function ‪compileReturnsResultChangedByDataProvider(): void
55  {
56  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
57  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
58  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
59 
60  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
61  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
62  $providerResult = ['foo'];
63  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
64 
65  $subject = new ‪OrderedProviderList();
66  $subject->setProviderList([
67  FormDataProviderInterface::class => [],
68  ]);
69  self::assertEquals($providerResult, $subject->compile([]));
70  }
71 
75  public function ‪compileDoesNotCallDisabledDataProvider(): void
76  {
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  self::assertEquals($input, $subject->compile($input));
89  }
90 
95  {
96  $orderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
97  GeneralUtility::addInstance(DependencyOrderingService::class, $orderingServiceProphecy->reveal());
98  $orderingServiceProphecy->orderByDependencies(Argument::cetera())->willReturnArgument(0);
99 
100  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
101  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
102 
103  $this->expectException(\UnexpectedValueException::class);
104  $this->expectExceptionCode(1485299408);
105 
106  $subject = new ‪OrderedProviderList();
107  $subject->setProviderList([
108  \stdClass::class => [],
109  ]);
110  $subject->compile([]);
111  }
112 }
‪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:93
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: OrderedProviderListTest.php:37
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup
Definition: FlexFormSegmentTest.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OrderedProviderListTest\compileDoesNotCallDisabledDataProvider
‪compileDoesNotCallDisabledDataProvider()
Definition: OrderedProviderListTest.php:74