‪TYPO3CMS  9.5
OnTheFlyTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Prophecy\Argument;
18 use Prophecy\Prophecy\ObjectProphecy;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪OnTheFlyTest extends UnitTestCase
28 {
32  protected ‪$subject;
33 
34  protected function ‪setUp()
35  {
36  $this->subject = new ‪OnTheFly();
37  }
38 
43  {
44  $this->expectException(\UnexpectedValueException::class);
45  $this->expectExceptionCode(1441108674);
46  $this->subject->compile([]);
47  }
48 
52  public function ‪compileReturnsIncomingData()
53  {
55  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
56  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
57  $formDataProviderProphecy->addData(Argument::cetera())->willReturnArgument(0);
58  $providerList = [
59  FormDataProviderInterface::class,
60  ];
61  $this->subject->setProviderList($providerList);
62 
63  $input = [
64  'foo',
65  ];
66 
67  $this->assertEquals($input, $this->subject->compile($input));
68  }
69 
74  {
76  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
77  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
78 
79  $providerList = [
80  FormDataProviderInterface::class,
81  ];
82  $this->subject->setProviderList($providerList);
83  $providerResult = ['foo'];
84  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
85 
86  $this->assertEquals($providerResult, $this->subject->compile([]));
87  }
88 
93  {
95  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
96  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
97  $providerList = [
98  \stdClass::class,
99  ];
100  $this->subject->setProviderList($providerList);
101 
102  $this->expectException(\UnexpectedValueException::class);
103  $this->expectExceptionCode(1441108719);
104  $this->subject->compile([]);
105  }
106 }
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileThrowsExceptionWithEmptyOnTheFlyList
‪compileThrowsExceptionWithEmptyOnTheFlyList()
Definition: OnTheFlyTest.php:41
‪TYPO3\CMS\Backend\Form\FormDataGroup\OnTheFly
Definition: OnTheFly.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\setUp
‪setUp()
Definition: OnTheFlyTest.php:33
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: OnTheFlyTest.php:51
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\$subject
‪OnTheFly $subject
Definition: OnTheFlyTest.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest
Definition: OnTheFlyTest.php:28
‪TYPO3\CMS\Backend\Form\FormDataProviderInterface
Definition: FormDataProviderInterface.php:22
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileThrowsExceptionIfDataProviderDoesNotImplementInterface
‪compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
Definition: OnTheFlyTest.php:91
‪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\OnTheFlyTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: OnTheFlyTest.php:72