TYPO3 CMS  TYPO3_8-7
FieldControlTest.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 
27 class FieldControlTest extends UnitTestCase
28 {
33  {
34  $languageServiceProphecy = $this->prophesize(LanguageService::class);
35  $languageServiceProphecy->sL(Argument::cetera())->willReturnArgument(0);
36  $GLOBALS['LANG'] = $languageServiceProphecy->reveal();
37 
38  $nodeFactoryProphecy = $this->prophesize(NodeFactory::class);
39  $data = [
40  'renderData' => [
41  'fieldControl' => [
42  'aControl' => [
43  'renderType' => 'aControl',
44  ],
45  'anotherControl' => [
46  'renderType' => 'anotherControl',
47  'after' => [ 'aControl' ],
48  ],
49  ],
50  ],
51  ];
52 
53  $aControlProphecy = $this->prophesize(AbstractNode::class);
54  $aControlProphecy->render()->willReturn(
55  [
56  'iconIdentifier' => 'actions-open',
57  'title' => 'aTitle',
58  'linkAttributes' => [ 'href' => '' ],
59  'additionalJavaScriptPost' => [ 'someJavaScript' ],
60  'requireJsModules' => [
61  'aModule',
62  ],
63  ]
64  );
65  $aControlNodeFactoryInput = $data;
66  $aControlNodeFactoryInput['renderData']['fieldControlOptions'] = [];
67  $aControlNodeFactoryInput['renderType'] = 'aControl';
68  $nodeFactoryProphecy->create($aControlNodeFactoryInput)->willReturn($aControlProphecy->reveal());
69 
70  $anotherControlProphecy = $this->prophesize(AbstractNode::class);
71  $anotherControlProphecy->render()->willReturn(
72  [
73  'iconIdentifier' => 'actions-close',
74  'title' => 'aTitle',
75  'linkAttributes' => [ 'href' => '' ],
76  'requireJsModules' => [
77  'anotherModule',
78  ],
79  ]
80  );
81  $anotherControlNodeFactoryInput = $data;
82  $anotherControlNodeFactoryInput['renderData']['fieldControlOptions'] = [];
83  $anotherControlNodeFactoryInput['renderType'] = 'anotherControl';
84  $nodeFactoryProphecy->create($anotherControlNodeFactoryInput)->willReturn($anotherControlProphecy->reveal());
85 
86  $expected = [
87  'additionalJavaScriptPost' => [
88  'someJavaScript',
89  ],
90  'additionalJavaScriptSubmit' => [],
91  'additionalHiddenFields' => [],
92  'additionalInlineLanguageLabelFiles' => [],
93  'stylesheetFiles' => [],
94  'requireJsModules' => [
95  'aModule',
96  'anotherModule',
97  ],
98  'inlineData' => [],
99  'html' => '\n<a class="btn btn-default">\n...>\n</a>'
100  ];
101  $result = (new FieldControl($nodeFactoryProphecy->reveal(), $data))->render();
102  // We're not interested in testing the html merge here
103  $expected['html'] = $result['html'];
104 
105  $this->assertEquals($expected, $result);
106  }
107 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']