‪TYPO3CMS  9.5
ClosureFinisherTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Prophecy\Argument;
19 use Prophecy\Prophecy\ObjectProphecy;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪ClosureFinisherTest extends UnitTestCase
29 {
30 
35  {
36  $closure = function (‪FinisherContext $finisherContext) {
37  return 'foobar';
38  };
39 
41  $mockClosureFinisher = $this->getAccessibleMock(ClosureFinisher::class, ['dummy'], [], '', false);
42 
43  $mockClosureFinisher->_set('options', [
44  'closure' => $closure
45  ]);
46 
47  $finisherContextProphecy = $this->prophesize(FinisherContext::class);
48  $formRuntimeProphecy = $this->prophesize(FormRuntime::class);
49  $finisherContextProphecy->getFormRuntime(Argument::cetera())->willReturn($formRuntimeProphecy->reveal());
50 
52  $revealedFinisherContext = $finisherContextProphecy->reveal();
53 
54  $mockClosureFinisher->_set('finisherContext', $revealedFinisherContext);
55  $closure = $mockClosureFinisher->_call('parseOption', 'closure');
56 
57  $this->assertSame('foobar', $closure($revealedFinisherContext));
58  }
59 }
‪TYPO3\CMS\Form\Domain\Finishers\ClosureFinisher
Definition: ClosureFinisher.php:38
‪TYPO3\CMS\Form\Tests\Unit\Domain\Finishers\ClosureFinisherTest\closureOptionForFinisherCanBeSetAndIsFunctional
‪closureOptionForFinisherCanBeSetAndIsFunctional()
Definition: ClosureFinisherTest.php:34
‪TYPO3\CMS\Form\Domain\Finishers\FinisherContext
Definition: FinisherContext.php:34
‪TYPO3\CMS\Form\Tests\Unit\Domain\Finishers\ClosureFinisherTest
Definition: ClosureFinisherTest.php:29
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormSession.php:3
‪TYPO3\CMS\Form\Tests\Unit\Domain\Finishers
Definition: AbstractFinisherTest.php:3