TYPO3 CMS  TYPO3_7-6
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 
23 
28 {
32  protected $subject;
33 
34  protected function setUp()
35  {
36  $this->subject = new OnTheFly();
37  }
38 
43  {
44  $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1441108674);
45  $this->subject->compile([]);
46  }
47 
51  public function compileReturnsIncomingData()
52  {
54  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
55  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
56  $formDataProviderProphecy->addData(Argument::cetera())->willReturnArgument(0);
57  $providerList = [
58  FormDataProviderInterface::class,
59  ];
60  $this->subject->setProviderList($providerList);
61 
62  $input = [
63  'foo',
64  ];
65 
66  $this->assertEquals($input, $this->subject->compile($input));
67  }
68 
72  public function compileReturnsResultChangedByDataProvider()
73  {
75  $formDataProviderProphecy = $this->prophesize(FormDataProviderInterface::class);
76  GeneralUtility::addInstance(FormDataProviderInterface::class, $formDataProviderProphecy->reveal());
77 
78  $providerList = [
79  FormDataProviderInterface::class,
80  ];
81  $this->subject->setProviderList($providerList);
82  $providerResult = ['foo'];
83  $formDataProviderProphecy->addData(Argument::cetera())->shouldBeCalled()->willReturn($providerResult);
84 
85  $this->assertEquals($providerResult, $this->subject->compile([]));
86  }
87 
91  public function compileThrowsExceptionIfDataProviderDoesNotImplementInterface()
92  {
94  $formDataProviderProphecy = $this->prophesize(\stdClass::class);
95  GeneralUtility::addInstance(\stdClass::class, $formDataProviderProphecy->reveal());
96  $providerList = [
97  \stdClass::class,
98  ];
99  $this->subject->setProviderList($providerList);
100 
101  $this->setExpectedException(\UnexpectedValueException::class, $this->anything(), 1441108719);
102  $this->subject->compile([]);
103  }
104 }
static addInstance($className, $instance)