2 declare(strict_types = 1);
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
41 $GLOBALS[
'TYPO3_CONF_VARS'][
'SYS'][
'encryptionKey'] =
'12345';
49 $mockController = $this->getAccessibleMock(FormEditorController::class, [
53 $objectManagerProphecy = $this->prophesize(ObjectManager::class);
54 GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
56 $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
60 $mockTranslationService
61 ->expects($this->any())
63 ->willReturnArgument(4);
65 $objectManagerProphecy
66 ->get(TranslationService::class)
67 ->willReturn($mockTranslationService);
69 $mockController->_set(
'prototypeConfiguration', [
71 'formElementGroups' => [
73 'label' =>
'Basic elements',
76 'label' =>
'Select elements',
85 'groupSorting' => 110,
86 'iconIdentifier' =>
'form-password',
87 'label' =>
'Password label',
91 'groupSorting' => 100,
92 'iconIdentifier' =>
'form-text',
93 'label' =>
'Text label',
97 'groupSorting' => 100,
98 'iconIdentifier' =>
'form-single-select',
99 'label' =>
'Single select label',
110 'label' =>
'Text label',
112 'iconIdentifier' =>
'form-text',
116 'cssKey' =>
'password',
117 'label' =>
'Password label',
119 'iconIdentifier' =>
'form-password',
122 'label' =>
'Basic elements',
128 'key' =>
'SingleSelect',
129 'cssKey' =>
'singleselect',
130 'label' =>
'Single select label',
132 'iconIdentifier' =>
'form-single-select',
135 'label' =>
'Select elements',
139 $this->assertSame($expected, $mockController->_call(
'getInsertRenderablesPanelConfiguration', $input));
147 $mockController = $this->getAccessibleMock(FormEditorController::class, [
151 $objectManagerProphecy = $this->prophesize(ObjectManager::class);
152 GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
154 $mockTranslationService = $this->getAccessibleMock(TranslationService::class, [
155 'translateValuesRecursive'
158 $mockTranslationService
159 ->expects($this->any())
160 ->method(
'translateValuesRecursive')
161 ->willReturnArgument(0);
163 $objectManagerProphecy
164 ->get(TranslationService::class)
165 ->willReturn($mockTranslationService);
167 $mockController->_set(
'prototypeConfiguration', [
169 'someOtherValues' => [
177 'formElementPropertyValidatorsDefinition' => [
183 'formElementsDefinition' => [
188 'someOtherValues' => [
201 'someOtherValues' => [
211 'finishersDefinition' => [
216 'someOtherValues' => [
229 'someOtherValues' => [
239 'someOtherValues' => [
266 'formElementPropertyValidators' => [
273 $this->assertSame($expected, $mockController->_call(
'getFormEditorDefinitions'));
281 $this->expectException(RenderingException::class);
282 $this->expectExceptionCode(1480294721);
284 $mockController = $this->getAccessibleMock(FormEditorController::class, [
288 $mockController->_set(
'prototypeConfiguration', [
290 'formEditorFluidConfiguration' => [
291 'templatePathAndFilename' =>
'',
296 $mockController->_call(
'renderFormEditorTemplates', []);
304 $this->expectException(RenderingException::class);
305 $this->expectExceptionCode(1480294721);
307 $mockController = $this->getAccessibleMock(FormEditorController::class, [
311 $mockController->_set(
'prototypeConfiguration', [
313 'formEditorFluidConfiguration' => [
314 'templatePathAndFilename' =>
'',
315 'layoutRootPaths' =>
'',
320 $mockController->_call(
'renderFormEditorTemplates', []);
328 $this->expectException(RenderingException::class);
329 $this->expectExceptionCode(1480294722);
331 $mockController = $this->getAccessibleMock(FormEditorController::class, [
335 $mockController->_set(
'prototypeConfiguration', [
337 'formEditorFluidConfiguration' => [
338 'templatePathAndFilename' =>
'',
339 'layoutRootPaths' => [],
344 $mockController->_call(
'renderFormEditorTemplates', []);
352 $this->expectException(RenderingException::class);
353 $this->expectExceptionCode(1480294722);
355 $mockController = $this->getAccessibleMock(FormEditorController::class, [
359 $mockController->_set(
'prototypeConfiguration', [
361 'formEditorFluidConfiguration' => [
362 'templatePathAndFilename' =>
'',
363 'layoutRootPaths' => [],
368 $mockController->_call(
'renderFormEditorTemplates', []);
376 $this->expectException(RenderingException::class);
377 $this->expectExceptionCode(1485636499);
379 $mockController = $this->getAccessibleMock(FormEditorController::class, [
383 $mockController->_set(
'prototypeConfiguration', [
385 'formEditorFluidConfiguration' => [],
389 $mockController->_call(
'renderFormEditorTemplates', []);
397 $mockController = $this->getAccessibleMock(FormEditorController::class, [
406 'type' =>
'SOMEELEMENT',
433 $multiValueProperties = [
435 0 =>
'properties.options',
444 'type' =>
'SOMEELEMENT',
460 [
'_label' =>
'5',
'_value' => 5],
461 [
'_label' =>
'4',
'_value' => 4],
462 [
'_label' =>
'3',
'_value' => 3],
463 [
'_label' =>
'2',
'_value' => 2],
464 [
'_label' =>
'1',
'_value' => 1],
471 $this->assertSame($expected, $mockController->_call(
'transformMultiValueElementsForFormEditor', $input, $multiValueProperties));
479 $mockController = $this->getAccessibleMock(FormEditorController::class, [
506 $this->assertSame($expected, $mockController->_call(
'filterEmptyArrays', $input));