TYPO3 CMS  TYPO3_8-7
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 
23 
27 class ClosureFinisherTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
29 
33  public function closureOptionForFinisherCanBeSetAndIsFunctional()
34  {
35  $closure = function (FinisherContext $finisherContext) {
36  return 'foobar';
37  };
38 
40  $mockClosureFinisher = $this->getAccessibleMock(ClosureFinisher::class, ['dummy'], [], '', false);
41 
42  $mockClosureFinisher->_set('options', [
43  'closure' => $closure
44  ]);
45 
46  $finisherContextProphecy = $this->prophesize(FinisherContext::class);
47  $formRuntimeProphecy = $this->prophesize(FormRuntime::class);
48  $finisherContextProphecy->getFormRuntime(Argument::cetera())->willReturn($formRuntimeProphecy->reveal());
49 
51  $revealedFinisherContext = $finisherContextProphecy->reveal();
52 
53  $mockClosureFinisher->_set('finisherContext', $revealedFinisherContext);
54  $closure = $mockClosureFinisher->_call('parseOption', 'closure');
55 
56  $this->assertSame('foobar', $closure($revealedFinisherContext));
57  }
58 }