‪TYPO3CMS  11.5
OnTheFlyTest.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;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪OnTheFlyTest extends UnitTestCase
31 {
32  use ProphecyTrait;
33 
34  protected ‪OnTheFly ‪$subject;
35 
36  protected function ‪setUp(): void
37  {
38  parent::setUp();
39  $this->subject = new ‪OnTheFly();
40  }
41 
46  {
47  $this->expectException(\UnexpectedValueException::class);
48  $this->expectExceptionCode(1441108674);
49  $this->subject->compile([]);
50  }
51 
55  public function ‪compileReturnsIncomingData(): void
56  {
57  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
58  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
59  $formDataProviderProphecy->addData(Argument::cetera())->willReturnArgument(0);
60  $providerList = [
61  FormDataProviderInterface::class,
62  ];
63  $this->subject->setProviderList($providerList);
64 
65  $input = [
66  'foo',
67  ];
68 
69  self::assertEquals($input, $this->subject->compile($input));
70  }
71 
75  public function ‪compileReturnsResultChangedByDataProvider(): void
76  {
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  {
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:44
‪TYPO3\CMS\Backend\Form\FormDataGroup\OnTheFly
Definition: OnTheFly.php:27
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\setUp
‪setUp()
Definition: OnTheFlyTest.php:35
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileReturnsIncomingData
‪compileReturnsIncomingData()
Definition: OnTheFlyTest.php:54
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\$subject
‪OnTheFly $subject
Definition: OnTheFlyTest.php:33
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest
Definition: OnTheFlyTest.php:31
‪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:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataGroup\OnTheFlyTest\compileReturnsResultChangedByDataProvider
‪compileReturnsResultChangedByDataProvider()
Definition: OnTheFlyTest.php:74