TYPO3 CMS  TYPO3_8-7
ConfigurationServiceTest.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 ConfigurationServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
29 
34  {
35  $mockConfigurationService = $this->getAccessibleMock(
36  ConfigurationService::class,
37  [
38  'dummy',
39  ],
40  [],
41  '',
42  false
43  );
44 
45  $mockConfigurationService->_set(
46  'formSettings',
47  [
48  'prototypes' => [
49  'standard' => [
50  'key' => 'value',
51  ],
52  ],
53  ]
54  );
55 
56  $expected = [
57  'key' => 'value',
58  ];
59 
60  $this->assertSame($expected, $mockConfigurationService->getPrototypeConfiguration('standard'));
61  }
62 
67  {
68  $mockConfigurationService = $this->getAccessibleMock(
69  ConfigurationService::class,
70  [
71  'dummy',
72  ],
73  [],
74  '',
75  false
76  );
77 
78  $this->expectException(PrototypeNotFoundException::class);
79  $this->expectExceptionCode(1475924277);
80 
81  $mockConfigurationService->_set(
82  'formSettings',
83  [
84  'prototypes' => [
85  'noStandard' => [],
86  ],
87  ]
88  );
89 
90  $mockConfigurationService->getPrototypeConfiguration('standard');
91  }
92 
97  {
98  $configurationService = $this->getAccessibleMock(ConfigurationService::class, ['dummy'], [], '', false);
99 
100  $configurationService->_set(
101  'formSettings',
102  [
103  'formManager' => [
104  'selectablePrototypesConfiguration' => [
105  0 => [
106  'identifier' => 'standard',
107  ],
108  1 => [
109  'identifier' => 'custom',
110  ],
111  'a' => [
112  'identifier' => 'custom-2',
113  ],
114  ],
115  ],
116  ]
117  );
118 
119  $expected = [
120  'standard',
121  'custom',
122  ];
123 
124  $this->assertSame($expected, $configurationService->getSelectablePrototypeNamesDefinedInFormEditorSetup());
125  }
126 
135  array $configuration,
136  ValidationDto $validationDto,
137  bool $expectedReturn
138  ) {
139  $configurationService = $this->getAccessibleMock(
140  ConfigurationService::class,
141  ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
142  [],
143  '',
144  false
145  );
146  $configurationService->expects($this->any())->method(
147  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
148  )->willReturn($configuration);
149 
150  $this->assertSame(
151  $expectedReturn,
152  $configurationService->isFormElementPropertyDefinedInFormEditorSetup($validationDto)
153  );
154  }
155 
164  array $configuration,
165  ValidationDto $validationDto,
166  bool $expectedReturn
167  ) {
168  $configurationService = $this->getAccessibleMock(
169  ConfigurationService::class,
170  ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
171  [],
172  '',
173  false
174  );
175  $configurationService->expects($this->any())->method(
176  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
177  )->willReturn($configuration);
178 
179  $this->assertSame(
180  $expectedReturn,
181  $configurationService->isPropertyCollectionPropertyDefinedInFormEditorSetup($validationDto)
182  );
183  }
184 
193  array $configuration,
194  ValidationDto $validationDto,
195  bool $expectedReturn
196  ) {
197  $configurationService = $this->getAccessibleMock(
198  ConfigurationService::class,
199  ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
200  [],
201  '',
202  false
203  );
204  $configurationService->expects($this->any())->method(
205  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
206  )->willReturn($configuration);
207 
208  $this->assertSame(
209  $expectedReturn,
210  $configurationService->isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup($validationDto)
211  );
212  }
213 
222  array $configuration,
223  ValidationDto $validationDto,
224  bool $expectedReturn
225  ) {
226  $configurationService = $this->getAccessibleMock(
227  ConfigurationService::class,
228  ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
229  [],
230  '',
231  false
232  );
233  $configurationService->expects($this->any())->method(
234  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
235  )->willReturn($configuration);
236 
237  $this->assertSame(
238  $expectedReturn,
239  $configurationService->isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup(
240  $validationDto
241  )
242  );
243  }
244 
249  ) {
250  $this->expectException(PropertyException::class);
251  $this->expectExceptionCode(1528578401);
252 
253  $configurationService = $this->getAccessibleMock(
254  ConfigurationService::class,
255  ['isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup'],
256  [],
257  '',
258  false
259  );
260  $configurationService->expects($this->any())->method(
261  'isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
262  )->willReturn(false);
263  $validationDto = new ValidationDto(null, 'Text', null, 'properties.foo.1');
264 
265  $configurationService->getFormElementPredefinedDefaultValueFromFormEditorSetup($validationDto);
266  }
267 
272  {
273  $expected = 'foo';
274  $configuration = ['formElements' => ['Text' => ['predefinedDefaults' => ['properties.foo.1' => $expected]]]];
275 
276  $configurationService = $this->getAccessibleMock(
277  ConfigurationService::class,
278  [
279  'buildFormDefinitionValidationConfigurationFromFormEditorSetup',
280  'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup',
281  ],
282  [],
283  '',
284  false
285  );
286  $configurationService->expects($this->any())->method(
287  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
288  )->willReturn($configuration);
289  $configurationService->expects($this->any())->method(
290  'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
291  )->willReturn(true);
292 
293  $validationDto = new ValidationDto('standard', 'Text', null, 'properties.foo.1');
294 
295  $this->assertSame(
296  $expected,
297  $configurationService->getFormElementPredefinedDefaultValueFromFormEditorSetup($validationDto)
298  );
299  }
300 
305  ) {
306  $this->expectException(PropertyException::class);
307  $this->expectExceptionCode(1528578402);
308 
309  $configurationService = $this->getAccessibleMock(
310  ConfigurationService::class,
311  ['isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup'],
312  [],
313  '',
314  false
315  );
316  $configurationService->expects($this->any())->method(
317  'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
318  )->willReturn(false);
319  $validationDto = new ValidationDto(
320  null,
321  null,
322  null,
323  'properties.foo.1',
324  'validators',
325  'StringLength'
326  );
327 
328  $configurationService->getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup($validationDto);
329  }
330 
335  {
336  $expected = 'foo';
337  $configuration = ['collections' => ['validators' => ['StringLength' => ['predefinedDefaults' => ['properties.foo.1' => $expected]]]]];
338 
339  $configurationService = $this->getAccessibleMock(
340  ConfigurationService::class,
341  [
342  'buildFormDefinitionValidationConfigurationFromFormEditorSetup',
343  'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup',
344  ],
345  [],
346  '',
347  false
348  );
349  $configurationService->expects($this->any())->method(
350  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
351  )->willReturn($configuration);
352  $configurationService->expects($this->any())->method(
353  'isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup'
354  )->willReturn(true);
355 
356  $validationDto = new ValidationDto(
357  'standard',
358  null,
359  null,
360  'properties.foo.1',
361  'validators',
362  'StringLength'
363  );
364 
365  $this->assertSame(
366  $expected,
367  $configurationService->getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup($validationDto)
368  );
369  }
370 
379  array $configuration,
380  ValidationDto $validationDto,
381  bool $expectedReturn
382  ) {
383  $configurationService = $this->getAccessibleMock(
384  ConfigurationService::class,
385  ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
386  [],
387  '',
388  false
389  );
390  $configurationService->expects($this->any())->method(
391  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
392  )->willReturn($configuration);
393 
394  $this->assertSame(
395  $expectedReturn,
396  $configurationService->isFormElementTypeCreatableByFormEditor($validationDto)
397  );
398  }
399 
408  array $configuration,
409  ValidationDto $validationDto,
410  bool $expectedReturn
411  ) {
412  $configurationService = $this->getAccessibleMock(
413  ConfigurationService::class,
414  ['buildFormDefinitionValidationConfigurationFromFormEditorSetup'],
415  [],
416  '',
417  false
418  );
419  $configurationService->expects($this->any())->method(
420  'buildFormDefinitionValidationConfigurationFromFormEditorSetup'
421  )->willReturn($configuration);
422 
423  $this->assertSame(
424  $expectedReturn,
425  $configurationService->isPropertyCollectionElementIdentifierCreatableByFormEditor($validationDto)
426  );
427  }
428 
433  {
434  $configuration = [
435  'formElementsDefinition' => [
436  'Text' => [],
437  ],
438  ];
439 
440  $configurationService = $this->getAccessibleMock(
441  ConfigurationService::class,
442  ['getPrototypeConfiguration'],
443  [],
444  '',
445  false
446  );
447  $configurationService->expects($this->any())->method('getPrototypeConfiguration')->willReturn($configuration);
448 
449  $validationDto = new ValidationDto('standard', 'Text');
450  $this->assertTrue($configurationService->isFormElementTypeDefinedInFormSetup($validationDto));
451 
452  $validationDto = new ValidationDto('standard', 'Foo');
453  $this->assertFalse($configurationService->isFormElementTypeDefinedInFormSetup($validationDto));
454  }
455 
460  {
461  $this->expectException(PropertyException::class);
462  $this->expectExceptionCode(1528633966);
463 
464  $configurationService = $this->getAccessibleMock(ConfigurationService::class, ['dummy'], [], '', false);
465  $input = ['dummy'];
466 
467  $configurationService->_call('addAdditionalPropertyPathsFromHook', '', '', $input, []);
468  }
469 
474  {
475  $this->expectException(PropertyException::class);
476  $this->expectExceptionCode(1528634966);
477 
478  $configurationService = $this->getAccessibleMock(ConfigurationService::class, ['dummy'], [], '', false);
479  $validationDto = new ValidationDto('Bar', 'Foo');
480  $input = [$validationDto];
481 
482  $configurationService->_call('addAdditionalPropertyPathsFromHook', '', 'standard', $input, []);
483  }
484 
489  {
490  $this->expectException(PropertyException::class);
491  $this->expectExceptionCode(1528633967);
492 
493  $configurationService = $this->getAccessibleMock(
494  ConfigurationService::class,
495  ['isFormElementTypeDefinedInFormSetup'],
496  [],
497  '',
498  false
499  );
500  $configurationService->expects($this->any())->method('isFormElementTypeDefinedInFormSetup')->willReturn(false);
501  $validationDto = new ValidationDto('standard', 'Text');
502  $input = [$validationDto];
503 
504  $configurationService->_call('addAdditionalPropertyPathsFromHook', '', 'standard', $input, []);
505  }
506 
511  {
512  $this->expectException(PropertyException::class);
513  $this->expectExceptionCode(1528636941);
514 
515  $configurationService = $this->getAccessibleMock(
516  ConfigurationService::class,
517  ['isFormElementTypeDefinedInFormSetup'],
518  [],
519  '',
520  false
521  );
522  $configurationService->expects($this->any())->method('isFormElementTypeDefinedInFormSetup')->willReturn(true);
523  $validationDto = new ValidationDto('standard', 'Text', null, null, 'Bar', 'Baz');
524  $input = [$validationDto];
525 
526  $configurationService->_call('addAdditionalPropertyPathsFromHook', '', 'standard', $input, []);
527  }
528 
533  {
534  $configurationService = $this->getAccessibleMock(
535  ConfigurationService::class,
536  ['isFormElementTypeDefinedInFormSetup'],
537  [],
538  '',
539  false
540  );
541  $configurationService->expects($this->any())->method('isFormElementTypeDefinedInFormSetup')->willReturn(true);
542 
543  $input = [
544  new ValidationDto('standard', 'Text', null, 'options.xxx', 'validators', 'Baz'),
545  new ValidationDto('standard', 'Text', null, 'options.yyy', 'validators', 'Baz'),
546  new ValidationDto('standard', 'Text', null, 'options.zzz', 'validators', 'Custom'),
547  new ValidationDto('standard', 'Text', null, 'properties.xxx'),
548  new ValidationDto('standard', 'Text', null, 'properties.yyy'),
549  new ValidationDto('standard', 'Custom', null, 'properties.xxx'),
550  ];
551  $expected = [
552  'formElements' => [
553  'Text' => [
554  'collections' => [
555  'validators' => [
556  'Baz' => [
557  'additionalPropertyPaths' => [
558  'options.xxx',
559  'options.yyy',
560  ],
561  ],
562  'Custom' => [
563  'additionalPropertyPaths' => [
564  'options.zzz',
565  ],
566  ],
567  ],
568  ],
569  'additionalPropertyPaths' => [
570  'properties.xxx',
571  'properties.yyy',
572  ],
573  ],
574  'Custom' => [
575  'additionalPropertyPaths' => [
576  'properties.xxx',
577  ],
578  ],
579  ],
580  ];
581 
582  $this->assertSame(
583  $expected,
584  $configurationService->_call('addAdditionalPropertyPathsFromHook', '', 'standard', $input, [])
585  );
586  }
587 
594  public function buildFormDefinitionValidationConfigurationFromFormEditorSetup(array $configuration, array $expected)
595  {
596  $configurationService = $this->getAccessibleMock(
597  ConfigurationService::class,
598  [
599  'getCacheEntry',
600  'getPrototypeConfiguration',
601  'getTranslationService',
602  'executeBuildFormDefinitionValidationConfigurationHooks',
603  'setCacheEntry',
604  ],
605  [],
606  '',
607  false
608  );
609 
610  $translationService = $this->getAccessibleMock(
611  TranslationService::class,
612  ['translateValuesRecursive'],
613  [],
614  '',
615  false
616  );
617  $translationService->expects($this->any())->method('translateValuesRecursive')->willReturnArgument(0);
618 
619  $configurationService->expects($this->any())->method('getCacheEntry')->willReturn(null);
620  $configurationService->expects($this->any())->method('getPrototypeConfiguration')->willReturn($configuration);
621  $configurationService->expects($this->any())->method('getTranslationService')->willReturn($translationService);
622  $configurationService->expects($this->any())
623  ->method('executeBuildFormDefinitionValidationConfigurationHooks')
624  ->willReturnArgument(1);
625  $configurationService->expects($this->any())->method('setCacheEntry')->willReturn(null);
626 
627  $this->assertSame(
628  $expected,
629  $configurationService->_call('buildFormDefinitionValidationConfigurationFromFormEditorSetup', 'standard')
630  );
631  }
632 
637  {
638  return [
639  [
640  ['formElements' => ['Text' => ['propertyPaths' => ['properties.foo.1']]]],
641  new ValidationDto('standard', 'Text', null, 'properties.foo.1'),
642  true,
643  ],
644  [
645  ['formElements' => ['Text' => ['additionalElementPropertyPaths' => ['properties.foo.1']]]],
646  new ValidationDto('standard', 'Text', null, 'properties.foo.1'),
647  true,
648  ],
649  [
650  ['formElements' => ['Text' => ['multiValueProperties' => ['properties.foo.1']]]],
651  new ValidationDto('standard', 'Text', null, 'properties.foo.1'),
652  true,
653  ],
654  [
655  ['formElements' => ['Text' => ['multiValueProperties' => ['properties.foo.1']]]],
656  new ValidationDto('standard', 'Text', null, 'properties.foo.1.bar'),
657  true,
658  ],
659  [
660  ['formElements' => ['Text' => ['additionalPropertyPaths' => ['properties.foo.1']]]],
661  new ValidationDto('standard', 'Text', null, 'properties.foo.1'),
662  true,
663  ],
664  [
665  ['formElements' => ['Text' => ['propertyPaths' => ['properties.foo.1']]]],
666  new ValidationDto('standard', 'Foo', null, 'properties.foo.1'),
667  false,
668  ],
669  [
670  ['formElements' => ['Text' => ['propertyPaths' => ['properties.foo.1']]]],
671  new ValidationDto('standard', 'Text', null, 'properties.bar.1'),
672  false,
673  ],
674  [
675  ['formElements' => ['Text' => ['additionalElementPropertyPaths' => ['properties.foo.1']]]],
676  new ValidationDto('standard', 'Foo', null, 'properties.foo.1'),
677  false,
678  ],
679  [
680  ['formElements' => ['Text' => ['additionalElementPropertyPaths' => ['properties.foo.1']]]],
681  new ValidationDto('standard', 'Text', null, 'properties.bar.1'),
682  false,
683  ],
684  [
685  ['formElements' => ['Text' => ['multiValueProperties' => ['properties.foo.1']]]],
686  new ValidationDto('standard', 'Foo', null, 'properties.foo.1'),
687  false,
688  ],
689  [
690  ['formElements' => ['Text' => ['multiValueProperties' => ['properties.foo.1']]]],
691  new ValidationDto('standard', 'Text', null, 'properties.bar.1'),
692  false,
693  ],
694  [
695  ['formElements' => ['Text' => ['multiValueProperties' => ['properties.foo.1']]]],
696  new ValidationDto('standard', 'Foo', null, 'properties.foo.1.bar'),
697  false,
698  ],
699  [
700  ['formElements' => ['Text' => ['multiValueProperties' => ['properties.foo.1']]]],
701  new ValidationDto('standard', 'Text', null, 'properties.bar.1.foo'),
702  false,
703  ],
704  [
705  ['formElements' => ['Text' => ['additionalPropertyPaths' => ['properties.foo.1']]]],
706  new ValidationDto('standard', 'Foo', null, 'properties.foo.1'),
707  false,
708  ],
709  [
710  ['formElements' => ['Text' => ['additionalPropertyPaths' => ['properties.foo.1']]]],
711  new ValidationDto('standard', 'Text', null, 'properties.bar.1'),
712  false,
713  ],
714  ];
715  }
716 
721  {
722  return [
723  [
724  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['propertyPaths' => ['properties.foo.1']]]]]]],
725  new ValidationDto(
726  'standard',
727  'Text',
728  null,
729  'properties.foo.1',
730  'validators',
731  'StringLength'
732  ),
733  true,
734  ],
735  [
736  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['multiValueProperties' => ['properties.foo.1']]]]]]],
737  new ValidationDto(
738  'standard',
739  'Text',
740  null,
741  'properties.foo.1',
742  'validators',
743  'StringLength'
744  ),
745  true,
746  ],
747  [
748  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['multiValueProperties' => ['properties.foo.1']]]]]]],
749  new ValidationDto(
750  'standard',
751  'Text',
752  null,
753  'properties.foo.1.bar',
754  'validators',
755  'StringLength'
756  ),
757  true,
758  ],
759  [
760  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['additionalPropertyPaths' => ['properties.foo.1']]]]]]],
761  new ValidationDto(
762  'standard',
763  'Text',
764  null,
765  'properties.foo.1',
766  'validators',
767  'StringLength'
768  ),
769  true,
770  ],
771  [
772  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['propertyPaths' => ['properties.foo.1']]]]]]],
773  new ValidationDto(
774  'standard',
775  'Text',
776  null,
777  'properties.foo.2',
778  'validators',
779  'StringLength'
780  ),
781  false,
782  ],
783  [
784  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['propertyPaths' => ['properties.foo.1']]]]]]],
785  new ValidationDto('standard', 'Foo', null, 'properties.foo.1', 'validators', 'StringLength'),
786  false,
787  ],
788  [
789  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['propertyPaths' => ['properties.foo.1']]]]]]],
790  new ValidationDto('standard', 'Text', null, 'properties.foo.1', 'foo', 'StringLength'),
791  false,
792  ],
793  [
794  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['propertyPaths' => ['properties.foo.1']]]]]]],
795  new ValidationDto('standard', 'Text', null, 'properties.foo.1', 'validators', 'Foo'),
796  false,
797  ],
798  [
799  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['multiValueProperties' => ['properties.foo.1']]]]]]],
800  new ValidationDto(
801  'standard',
802  'Text',
803  null,
804  'properties.foo.2',
805  'validators',
806  'StringLength'
807  ),
808  false,
809  ],
810  [
811  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['multiValueProperties' => ['properties.foo.1']]]]]]],
812  new ValidationDto(
813  'standard',
814  'Foo',
815  null,
816  'properties.foo.1.bar',
817  'validators',
818  'StringLength'
819  ),
820  false,
821  ],
822  [
823  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['multiValueProperties' => ['properties.foo.1']]]]]]],
824  new ValidationDto('standard', 'Text', null, 'properties.foo.1.bar', 'foo', 'StringLength'),
825  false,
826  ],
827  [
828  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['multiValueProperties' => ['properties.foo.1']]]]]]],
829  new ValidationDto('standard', 'Text', null, 'properties.foo.1.bar', 'validators', 'Foo'),
830  false,
831  ],
832  [
833  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['additionalPropertyPaths' => ['properties.foo.1']]]]]]],
834  new ValidationDto('standard', 'Foo', null, 'properties.foo.1', 'validators', 'StringLength'),
835  false,
836  ],
837  [
838  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['additionalPropertyPaths' => ['properties.foo.1']]]]]]],
839  new ValidationDto('standard', 'Text', null, 'properties.foo.1', 'foo', 'StringLength'),
840  false,
841  ],
842  [
843  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['additionalPropertyPaths' => ['properties.foo.1']]]]]]],
844  new ValidationDto('standard', 'Text', null, 'properties.foo.1', 'validators', 'Foo'),
845  false,
846  ],
847  ];
848  }
849 
854  {
855  return [
856  [
857  ['formElements' => ['Text' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]],
858  new ValidationDto('standard', 'Text', null, 'properties.foo.1'),
859  true,
860  ],
861  [
862  ['formElements' => ['Text' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]],
863  new ValidationDto('standard', 'Text', null, 'properties.foo.2'),
864  false,
865  ],
866  [
867  ['formElements' => ['Text' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]],
868  new ValidationDto('standard', 'Foo', null, 'properties.foo.1'),
869  false,
870  ],
871  ];
872  }
873 
878  {
879  return [
880  [
881  ['collections' => ['validators' => ['StringLength' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]]],
882  new ValidationDto('standard', null, null, 'properties.foo.1', 'validators', 'StringLength'),
883  true,
884  ],
885  [
886  ['collections' => ['validators' => ['StringLength' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]]],
887  new ValidationDto('standard', null, null, 'properties.foo.2', 'validators', 'StringLength'),
888  false,
889  ],
890  [
891  ['collections' => ['validators' => ['StringLength' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]]],
892  new ValidationDto('standard', null, null, 'properties.foo.1', 'foo', 'StringLength'),
893  false,
894  ],
895  [
896  ['collections' => ['validators' => ['StringLength' => ['predefinedDefaults' => ['properties.foo.1' => 'bar']]]]],
897  new ValidationDto('standard', null, null, 'properties.foo.1', 'validators', 'Foo'),
898  false,
899  ],
900  ];
901  }
902 
907  {
908  return [
909  [
910  [],
911  new ValidationDto('standard', 'Form'),
912  true,
913  ],
914  [
915  ['formElements' => ['Text' => ['creatable' => true]]],
916  new ValidationDto('standard', 'Text'),
917  true,
918  ],
919  [
920  ['formElements' => ['Text' => ['creatable' => false]]],
921  new ValidationDto('standard', 'Text'),
922  false,
923  ],
924  [
925  ['formElements' => ['Foo' => ['creatable' => true]]],
926  new ValidationDto('standard', 'Text'),
927  false,
928  ],
929  ];
930  }
931 
936  {
937  return [
938  [
939  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['creatable' => true]]]]]],
940  new ValidationDto('standard', 'Text', null, null, 'validators', 'StringLength'),
941  true,
942  ],
943  [
944  ['formElements' => ['Text' => ['collections' => ['validators' => ['StringLength' => ['creatable' => false]]]]]],
945  new ValidationDto('standard', 'Text', null, null, 'validators', 'StringLength'),
946  false,
947  ],
948  [
949  ['formElements' => ['Foo' => ['collections' => ['validators' => ['StringLength' => ['creatable' => true]]]]]],
950  new ValidationDto('standard', 'Text', null, null, 'validators', 'StringLength'),
951  false,
952  ],
953  [
954  ['formElements' => ['Text' => ['collections' => ['foo' => ['StringLength' => ['creatable' => true]]]]]],
955  new ValidationDto('standard', 'Text', null, null, 'validators', 'StringLength'),
956  false,
957  ],
958  [
959  ['formElements' => ['Text' => ['collections' => ['validators' => ['Foo' => ['creatable' => true]]]]]],
960  new ValidationDto('standard', 'Text', null, null, 'validators', 'StringLength'),
961  false,
962  ],
963  ];
964  }
965 
970  {
971  return [
972  [
973  [
974  'formElementsDefinition' => [
975  'Text' => [
976  'formEditor' => [
977  'editors' => [
978  [
979  'templateName' => 'Foo',
980  'propertyPath' => 'properties.foo',
981  'setup' => [
982  'propertyPath' => 'properties.bar',
983  ],
984  ],
985  ],
986  ],
987  ],
988  ],
989  ],
990  [
991  'formElements' => [
992  'Text' => [
993  'propertyPaths' => [
994  'properties.foo',
995  'properties.bar',
996  ],
997  ],
998  ],
999  ],
1000  ],
1001 
1002  [
1003  [
1004  'formElementsDefinition' => [
1005  'Text' => [
1006  'formEditor' => [
1007  'editors' => [
1008  [
1009  'templateName' => 'Inspector-GridColumnViewPortConfigurationEditor',
1010  'propertyPath' => 'properties.{@viewPortIdentifier}.foo',
1011  'configurationOptions' => [
1012  'viewPorts' => [
1013  ['viewPortIdentifier' => 'viewFoo'],
1014  ['viewPortIdentifier' => 'viewBar'],
1015  ],
1016  ],
1017  ],
1018  ],
1019  ],
1020  ],
1021  ],
1022  ],
1023  [
1024  'formElements' => [
1025  'Text' => [
1026  'propertyPaths' => [
1027  'properties.viewFoo.foo',
1028  'properties.viewBar.foo',
1029  ],
1030  ],
1031  ],
1032  ],
1033  ],
1034 
1035  [
1036  [
1037  'formElementsDefinition' => [
1038  'Text' => [
1039  'formEditor' => [
1040  'editors' => [
1041  [
1042  'additionalElementPropertyPaths' => [
1043  'properties.foo',
1044  'properties.bar',
1045  ],
1046  ],
1047  ],
1048  ],
1049  ],
1050  ],
1051  ],
1052  [
1053  'formElements' => [
1054  'Text' => [
1055  'additionalElementPropertyPaths' => [
1056  'properties.foo',
1057  'properties.bar',
1058  ],
1059  ],
1060  ],
1061  ],
1062  ],
1063 
1064  [
1065  [
1066  'formElementsDefinition' => [
1067  'Text' => [
1068  'formEditor' => [
1069  'editors' => [
1070  [
1071  'templateName' => 'Inspector-PropertyGridEditor',
1072  'propertyPath' => 'properties.foo.1',
1073  ],
1074  [
1075  'templateName' => 'Inspector-MultiSelectEditor',
1076  'propertyPath' => 'properties.foo.2',
1077  ],
1078  [
1079  'templateName' => 'Inspector-ValidationErrorMessageEditor',
1080  'propertyPath' => 'properties.foo.3',
1081  ],
1082  [
1083  'templateName' => 'Inspector-RequiredValidatorEditor',
1084  'propertyPath' => 'properties.fluidAdditionalAttributes.required',
1085  'configurationOptions' => [
1086  'validationErrorMessage' => [
1087  'propertyPath' => 'properties.validationErrorMessages',
1088  ],
1089  ],
1090  ],
1091  ],
1092  ],
1093  ],
1094  ],
1095  ],
1096  [
1097  'formElements' => [
1098  'Text' => [
1099  'multiValueProperties' => [
1100  'properties.foo.1',
1101  'defaultValue',
1102  'properties.foo.2',
1103  'properties.foo.3',
1104  'properties.validationErrorMessages',
1105  ],
1106  'propertyPaths' => [
1107  'properties.foo.1',
1108  'properties.foo.2',
1109  'properties.foo.3',
1110  'properties.fluidAdditionalAttributes.required',
1111  'properties.validationErrorMessages',
1112  ],
1113  ],
1114  ],
1115  ],
1116  ],
1117 
1118  [
1119  [
1120  'formElementsDefinition' => [
1121  'Text' => [
1122  'formEditor' => [
1123  'predefinedDefaults' => [
1124  'foo' => [
1125  'bar' => 'xxx',
1126  ],
1127  ],
1128  ],
1129  ],
1130  ],
1131  ],
1132  [
1133  'formElements' => [
1134  'Text' => [
1135  'predefinedDefaults' => [
1136  'foo.bar' => 'xxx',
1137  ],
1138  ],
1139  ],
1140  ],
1141  ],
1142 
1143  [
1144  [
1145  'formEditor' => [
1146  'formElementGroups' => [
1147  'Dummy' => [],
1148  ],
1149  ],
1150  'formElementsDefinition' => [
1151  'Text' => [
1152  'formEditor' => [
1153  'group' => 'Dummy',
1154  'groupSorting' => 10,
1155  ],
1156  ],
1157  ],
1158  ],
1159  [
1160  'formElements' => [
1161  'Text' => [
1162  'creatable' => true,
1163  ],
1164  ],
1165  ],
1166  ],
1167 
1168  [
1169  [
1170  'formEditor' => [
1171  'formElementGroups' => [
1172  'Dummy' => [],
1173  ],
1174  ],
1175  'formElementsDefinition' => [
1176  'Text' => [
1177  'formEditor' => [
1178  'group' => 'Dummy',
1179  ],
1180  ],
1181  ],
1182  ],
1183  [
1184  'formElements' => [
1185  'Text' => [
1186  'creatable' => false,
1187  ],
1188  ],
1189  ],
1190  ],
1191 
1192  [
1193  [
1194  'formEditor' => [
1195  'formElementGroups' => [
1196  'Foo' => [],
1197  ],
1198  ],
1199  'formElementsDefinition' => [
1200  'Text' => [
1201  'formEditor' => [
1202  'group' => 'Dummy',
1203  'groupSorting' => 10,
1204  ],
1205  ],
1206  ],
1207  ],
1208  [
1209  'formElements' => [
1210  'Text' => [
1211  'creatable' => false,
1212  ],
1213  ],
1214  ],
1215  ],
1216 
1217  [
1218  [
1219  'formEditor' => [
1220  'formElementGroups' => [
1221  'Dummy' => [],
1222  ],
1223  ],
1224  'formElementsDefinition' => [
1225  'Text' => [
1226  'formEditor' => [
1227  'group' => 'Foo',
1228  'groupSorting' => 10,
1229  ],
1230  ],
1231  ],
1232  ],
1233  [
1234  'formElements' => [
1235  'Text' => [
1236  'creatable' => false,
1237  ],
1238  ],
1239  ],
1240  ],
1241 
1242  [
1243  [
1244  'formElementsDefinition' => [
1245  'Text' => [
1246  'formEditor' => [
1247  'editors' => [
1248  [
1249  'templateName' => 'Inspector-FinishersEditor',
1250  'selectOptions' => [
1251  [
1252  'value' => 'FooFinisher',
1253  ],
1254  [
1255  'value' => 'BarFinisher',
1256  ],
1257  ],
1258  ],
1259  [
1260  'templateName' => 'Inspector-ValidatorsEditor',
1261  'selectOptions' => [
1262  [
1263  'value' => 'FooValidator',
1264  ],
1265  [
1266  'value' => 'BarValidator',
1267  ],
1268  ],
1269  ],
1270  [
1271  'templateName' => 'Inspector-RequiredValidatorEditor',
1272  'validatorIdentifier' => 'NotEmpty',
1273  ],
1274  ],
1275  ],
1276  ],
1277  ],
1278  ],
1279  [
1280  'formElements' => [
1281  'Text' => [
1282  'collections' => [
1283  'finishers' => [
1284  'FooFinisher' => [
1285  'creatable' => true,
1286  ],
1287  'BarFinisher' => [
1288  'creatable' => true,
1289  ],
1290  ],
1291  'validators' => [
1292  'FooValidator' => [
1293  'creatable' => true,
1294  ],
1295  'BarValidator' => [
1296  'creatable' => true,
1297  ],
1298  'NotEmpty' => [
1299  'creatable' => true,
1300  ],
1301  ],
1302  ],
1303  ],
1304  ],
1305  ],
1306  ],
1307 
1308  [
1309  [
1310  'formElementsDefinition' => [
1311  'Text' => [
1312  'formEditor' => [
1313  'propertyCollections' => [
1314  'validators' => [
1315  [
1316  'identifier' => 'fooValidator',
1317  'editors' => [
1318  [
1319  'propertyPath' => 'options.xxx',
1320  ],
1321  [
1322  'propertyPath' => 'options.yyy',
1323  'setup' => [
1324  'propertyPath' => 'options.zzz',
1325  ],
1326  ],
1327  ],
1328  ],
1329  ],
1330  ],
1331  ],
1332  ],
1333  ],
1334  ],
1335  [
1336  'formElements' => [
1337  'Text' => [
1338  'collections' => [
1339  'validators' => [
1340  'fooValidator' => [
1341  'propertyPaths' => [
1342  'options.xxx',
1343  'options.yyy',
1344  'options.zzz',
1345  ],
1346  ],
1347  ],
1348  ],
1349  ],
1350  ],
1351  ],
1352  ],
1353 
1354  [
1355  [
1356  'formElementsDefinition' => [
1357  'Text' => [
1358  'formEditor' => [
1359  'propertyCollections' => [
1360  'validators' => [
1361  [
1362  'identifier' => 'fooValidator',
1363  'editors' => [
1364  [
1365  'additionalElementPropertyPaths' => [
1366  'options.xxx',
1367  ],
1368  ],
1369  [
1370  'additionalElementPropertyPaths' => [
1371  'options.yyy',
1372  'options.zzz',
1373  ],
1374  ],
1375  ],
1376  ],
1377  ],
1378  ],
1379  ],
1380  ],
1381  ],
1382  ],
1383  [
1384  'formElements' => [
1385  'Text' => [
1386  'additionalElementPropertyPaths' => [
1387  'options.xxx',
1388  'options.yyy',
1389  'options.zzz',
1390  ],
1391  ],
1392  ],
1393  ],
1394  ],
1395 
1396  [
1397  [
1398  'formElementsDefinition' => [
1399  'Text' => [
1400  'formEditor' => [
1401  'propertyCollections' => [
1402  'validators' => [
1403  [
1404  'identifier' => 'fooValidator',
1405  'editors' => [
1406  [
1407  'templateName' => 'Inspector-PropertyGridEditor',
1408  'propertyPath' => 'options.xxx',
1409  ],
1410  [
1411  'templateName' => 'Inspector-MultiSelectEditor',
1412  'propertyPath' => 'options.yyy',
1413  ],
1414  [
1415  'templateName' => 'Inspector-ValidationErrorMessageEditor',
1416  'propertyPath' => 'options.zzz',
1417  ],
1418  ],
1419  ],
1420  ],
1421  ],
1422  ],
1423  ],
1424  ],
1425  ],
1426  [
1427  'formElements' => [
1428  'Text' => [
1429  'collections' => [
1430  'validators' => [
1431  'fooValidator' => [
1432  'multiValueProperties' => [
1433  'options.xxx',
1434  'defaultValue',
1435  'options.yyy',
1436  ],
1437  'propertyPaths' => [
1438  'options.xxx',
1439  'options.yyy',
1440  'options.zzz',
1441  ],
1442  ],
1443  ],
1444  ],
1445  'multiValueProperties' => [
1446  'options.zzz',
1447  ],
1448  ],
1449  ],
1450  ],
1451  ],
1452 
1453  [
1454  [
1455  'validatorsDefinition' => [
1456  'someValidator' => [
1457  'formEditor' => [
1458  'predefinedDefaults' => [
1459  'some' => [
1460  'property' => 'value',
1461  ],
1462  ],
1463  ],
1464  ],
1465  ],
1466  ],
1467  [
1468  'collections' => [
1469  'validators' => [
1470  'someValidator' => [
1471  'predefinedDefaults' => [
1472  'some.property' => 'value',
1473  ],
1474  ],
1475  ],
1476  ],
1477  ],
1478  ],
1479  ];
1480  }
1481 }
isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup(array $configuration, ValidationDto $validationDto, bool $expectedReturn)
isPropertyCollectionPropertyDefinedInPredefinedDefaultsInFormEditorSetup(array $configuration, ValidationDto $validationDto, bool $expectedReturn)
isFormElementTypeCreatableByFormEditor(array $configuration, ValidationDto $validationDto, bool $expectedReturn)
isFormElementPropertyDefinedInFormEditorSetup(array $configuration, ValidationDto $validationDto, bool $expectedReturn)
isPropertyCollectionElementIdentifierCreatableByFormEditor(array $configuration, ValidationDto $validationDto, bool $expectedReturn)
isPropertyCollectionPropertyDefinedInFormEditorSetup(array $configuration, ValidationDto $validationDto, bool $expectedReturn)
buildFormDefinitionValidationConfigurationFromFormEditorSetup(array $configuration, array $expected)