2 declare(strict_types = 1);
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
31 $this->expectException(PropertyException::class);
32 $this->expectExceptionCode(1528588035);
34 $validationDto =
new ValidationDto(
'standard',
null,
'test-1',
'label');
36 $typeConverter = $this->getAccessibleMock(
37 CreatableFormElementPropertiesValidator::class,
38 [
'getConfigurationService'],
39 [[],
'', $validationDto]
41 $configurationService = $this->createMock(ConfigurationService::class);
42 $configurationService->expects($this->any())
43 ->method(
'getFormElementPredefinedDefaultValueFromFormEditorSetup')
44 ->willReturn(
'default');
45 $configurationService->expects($this->any())
46 ->method(
'isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup')
48 $typeConverter->expects($this->any())->method(
'getConfigurationService')->willReturn($configurationService);
50 $typeConverter($input,
'');
58 $validationDto =
new ValidationDto(
null,
null,
'test-1',
'label');
59 $typeConverter = $this->getAccessibleMock(
60 CreatableFormElementPropertiesValidator::class,
61 [
'getConfigurationService'],
62 [[],
'', $validationDto]
64 $configurationService = $this->createMock(ConfigurationService::class);
65 $configurationService->expects($this->any())
66 ->method(
'getFormElementPredefinedDefaultValueFromFormEditorSetup')
67 ->willReturn(
'default');
68 $configurationService->expects($this->any())
69 ->method(
'isFormElementPropertyDefinedInPredefinedDefaultsInFormEditorSetup')
71 $typeConverter->expects($this->any())->method(
'getConfigurationService')->willReturn($configurationService);
75 $typeConverter(
'',
'default');
79 $this->assertFalse($failed);
87 'allowedValues' => [],
88 'untranslatedAllowedValues' => [],
92 'allowedValues' => [
'bar',
'baz'],
93 'untranslatedAllowedValues' => [
'bar',
'baz'],
97 'allowedValues' => [
'bar',
'baz'],
98 'untranslatedAllowedValues' => [
'bar',
'world'],
102 'allowedValues' => [
'1', 2],
103 'untranslatedAllowedValues' => [
'1', 2],
114 $this->expectException(PropertyException::class);
116 $validationDto =
new ValidationDto(
'standard',
null,
'test-1',
'label');
117 $validatorMock = $this->getAccessibleMock(
118 CreatableFormElementPropertiesValidator::class,
119 [
'getConfigurationService'],
120 [[],
'', $validationDto]
123 $configurationServiceMock = $this->createMock(ConfigurationService::class);
124 $configurationServiceMock->expects(self::any())->method(
125 'getAllowedValuesForFormElementPropertyFromFormEditorSetup'
127 [$validationDto,
true, $allowedValues],
128 [$validationDto,
false, $untranslatedAllowedValues],
131 $validatorMock->expects(self::any())->method(
'getConfigurationService')->willReturn($configurationServiceMock);
133 $validatorMock->_call(
'validateFormElementValue', $input, $validationDto);
141 'allowedValues' => [
'foo'],
142 'untranslatedAllowedValues' => [
'foo'],
143 'allPossibleAllowedValuesTranslations' => [],
147 'allowedValues' => [
'bar'],
148 'untranslatedAllowedValues' => [
'foo'],
149 'allPossibleAllowedValuesTranslations' => [],
153 'allowedValues' => [
'bar'],
154 'untranslatedAllowedValues' => [
'baz'],
155 'allPossibleAllowedValuesTranslations' => [
'default' => [
'foo'],
'de' => [
'bar']],
159 'allowedValues' => [
'foo',
'baz'],
160 'untranslatedAllowedValues' => [
'foo',
'baz'],
161 'allPossibleAllowedValuesTranslations' => [],
165 'allowedValues' => [
'1', 1, 2],
166 'untranslatedAllowedValues' => [
'1', 1, 2],
167 'allPossibleAllowedValuesTranslations' => [],
178 $validationDto =
new ValidationDto(
'standard',
null,
'test-1',
'label');
179 $validatorMock = $this->getAccessibleMock(
180 CreatableFormElementPropertiesValidator::class,
181 [
'getConfigurationService'],
182 [[],
'', $validationDto]
185 $configurationServiceMock = $this->createMock(ConfigurationService::class);
186 $configurationServiceMock->expects(self::any())->method(
187 'getAllowedValuesForFormElementPropertyFromFormEditorSetup'
189 [$validationDto,
true, $allowedValues],
190 [$validationDto,
false, $untranslatedAllowedValues],
192 $configurationServiceMock->expects(self::any())->method(
'getAllBackendTranslationsForTranslationKeys')->willReturn($allPossibleAllowedValuesTranslations);
193 $validatorMock->expects(self::any())->method(
'getConfigurationService')->willReturn($configurationServiceMock);
197 $validatorMock->_call(
'validateFormElementValue', $input, $validationDto);
201 self::assertFalse($failed);