‪TYPO3CMS  10.4
OnTheFlyTest.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;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪OnTheFlyTest extends UnitTestCase
29 {
33  protected ‪$subject;
34 
35  protected function ‪setUp(): void
36  {
37  $this->subject = new ‪OnTheFly();
38  }
39 
44  {
45  $this->expectException(\UnexpectedValueException::class);
46  $this->expectExceptionCode(1441108674);
47  $this->subject->compile([]);
48  }
49 
53  public function ‪compileReturnsIncomingData()
54  {
56  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
57  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
58  $formDataProviderProphecy->addData(Argument::cetera())->willReturnArgument(0);
59  $providerList = [
60  FormDataProviderInterface::class,
61  ];
62  $this->subject->setProviderList($providerList);
63 
64  $input = [
65  'foo',
66  ];
67 
68  self::assertEquals($input, $this->subject->compile($input));
69  }
70 
75  {
77  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
78  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
79 
80  $providerList = [
81  FormDataProviderInterface::class,
82  ];
83  $this->subject->setProviderList($providerList);
84  $providerResult = ['foo'];
85  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
86 
87  self::assertEquals($providerResult, $this->subject->compile([]));
88  }
89 
94  {
96  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
97  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
98  $providerList = [
99  \stdClass::class,
100  ];
101  $this->subject->setProviderList($providerList);
102 
103  $this->expectException(\UnexpectedValueException::class);
104  $this->expectExceptionCode(1441108719);
105  $this->subject->compile([]);
106  }
107 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileThrowsExceptionWithEmptyOnTheFlyList
‪compileThrowsExceptionWithEmptyOnTheFlyList()
Definition: OnTheFlyTest.php:42
‪TYPO3\CMS\Backend\Form\FormDataGroup\OnTheFly
Definition: OnTheFly.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\setUp
‪setUp()
Definition: OnTheFlyTest.php:34
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: OnTheFlyTest.php:52
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\$subject
‪OnTheFly $subject
Definition: OnTheFlyTest.php:32
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest
Definition: OnTheFlyTest.php:29
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:23
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: OnTheFlyTest.php:92
‪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\OnTheFlyTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: OnTheFlyTest.php:73