‪TYPO3CMS  10.4
ClosureFinisherTest.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\Prophecy\ObjectProphecy;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪ClosureFinisherTest extends UnitTestCase
31 {
32 
37  {
38  $closure = function (‪FinisherContext $finisherContext) {
39  return 'foobar';
40  };
41 
43  $mockClosureFinisher = $this->getAccessibleMock(ClosureFinisher::class, ['dummy'], [], '', false);
44 
45  $mockClosureFinisher->_set('options', [
46  'closure' => $closure
47  ]);
48 
49  $finisherContextProphecy = $this->prophesize(FinisherContext::class);
50  $formRuntimeProphecy = $this->prophesize(FormRuntime::class);
51  $finisherContextProphecy->getFormRuntime(Argument::cetera())->willReturn($formRuntimeProphecy->reveal());
52 
54  $revealedFinisherContext = $finisherContextProphecy->reveal();
55 
56  $mockClosureFinisher->_set('finisherContext', $revealedFinisherContext);
57  $closure = $mockClosureFinisher->_call('parseOption', 'closure');
58 
59  self::assertSame('foobar', $closure($revealedFinisherContext));
60  }
61 }
‪TYPO3\CMS\Form\Domain\Finishers\ClosureFinisher
Definition: ClosureFinisher.php:42
‪TYPO3\CMS\Form\Tests\Unit\Domain\Finishers\ClosureFinisherTest\closureOptionForFinisherCanBeSetAndIsFunctional
‪closureOptionForFinisherCanBeSetAndIsFunctional()
Definition: ClosureFinisherTest.php:36
‪TYPO3\CMS\Form\Domain\Finishers\FinisherContext
Definition: FinisherContext.php:37
‪TYPO3\CMS\Form\Tests\Unit\Domain\Finishers\ClosureFinisherTest
Definition: ClosureFinisherTest.php:31
‪TYPO3\CMS\Form\Domain\Runtime\FormRuntime
Definition: FormSession.php:18
‪TYPO3\CMS\Form\Tests\Unit\Domain\Finishers
Definition: AbstractFinisherTest.php:18