2 declare(strict_types = 1);
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
32 $this->expectException(PropertyException::class);
33 $this->expectExceptionCode(1528591502);
35 $validationDto =
new ValidationDto(
'standard',
null,
'test-1',
'label',
'validators',
'StringLength');
36 $typeConverter = $this->getAccessibleMock(
37 CreatablePropertyCollectionElementPropertiesValidator::class,
38 [
'getConfigurationService'],
39 [[],
'', $validationDto]
41 $configurationService = $this->createMock(ConfigurationService::class);
42 $configurationService->expects($this->any())->method(
43 'getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup'
44 )->willReturn(
'default');
45 $typeConverter->expects($this->any())->method(
'getConfigurationService')->willReturn($configurationService);
48 $typeConverter->_call(
'validatePropertyCollectionElementPredefinedDefaultValue', $input, $validationDto);
56 $validationDto =
new ValidationDto(
null,
null,
'test-1',
'label',
'validators',
'StringLength');
57 $typeConverter = $this->getAccessibleMock(
58 CreatablePropertyCollectionElementPropertiesValidator::class,
59 [
'getConfigurationService'],
60 [[],
'', $validationDto]
62 $configurationService = $this->createMock(ConfigurationService::class);
63 $configurationService->expects($this->any())->method(
64 'getPropertyCollectionPredefinedDefaultValueFromFormEditorSetup'
65 )->willReturn(
'default');
66 $typeConverter->expects($this->any())->method(
'getConfigurationService')->willReturn($configurationService);
72 $typeConverter->_call(
'validatePropertyCollectionElementPredefinedDefaultValue', $input, $validationDto);
76 $this->assertFalse($failed);
84 'allowedValues' => [],
85 'untranslatedAllowedValues' => [],
89 'allowedValues' => [
'bar',
'baz'],
90 'untranslatedAllowedValues' => [
'bar',
'baz'],
94 'allowedValues' => [
'1', 2],
95 'untranslatedAllowedValues' => [
'1', 2],
106 $this->expectException(PropertyException::class);
108 $validationDto =
new ValidationDto(
'standard',
null,
'test-1',
'label',
'validators',
'StringLength');
109 $validatorMock = $this->getAccessibleMock(
110 CreatablePropertyCollectionElementPropertiesValidator::class,
111 [
'getConfigurationService'],
112 [[],
'', $validationDto]
115 $configurationServiceMock = $this->createMock(ConfigurationService::class);
116 $configurationServiceMock->expects(self::any())->method(
117 'getAllowedValuesForPropertyCollectionPropertyFromFormEditorSetup'
119 [$validationDto,
true, $allowedValues],
120 [$validationDto,
false, $untranslatedAllowedValues],
123 $validatorMock->expects(self::any())->method(
'getConfigurationService')->willReturn($configurationServiceMock);
125 $validatorMock->_call(
'validatePropertyCollectionPropertyValue', $input, $validationDto);
133 'allowedValues' => [
'foo'],
134 'untranslatedAllowedValues' => [
'foo'],
135 'allPossibleAllowedValuesTranslations' => [],
139 'allowedValues' => [
'bar'],
140 'untranslatedAllowedValues' => [
'foo'],
141 'allPossibleAllowedValuesTranslations' => [],
145 'allowedValues' => [
'bar'],
146 'untranslatedAllowedValues' => [
'baz'],
147 'allPossibleAllowedValuesTranslations' => [
'default' => [
'foo'],
'de' => [
'bar']],
151 'allowedValues' => [
'foo',
'baz'],
152 'untranslatedAllowedValues' => [
'foo',
'baz'],
153 'allPossibleAllowedValuesTranslations' => [],
157 'allowedValues' => [
'1', 1, 2],
158 'untranslatedAllowedValues' => [
'1', 1, 2],
159 'allPossibleAllowedValuesTranslations' => [],
170 $validationDto =
new ValidationDto(
'standard',
null,
'test-1',
'label',
'validators',
'StringLength');
171 $validatorMock = $this->getAccessibleMock(
172 CreatablePropertyCollectionElementPropertiesValidator::class,
173 [
'getConfigurationService'],
174 [[],
'', $validationDto]
177 $configurationServiceMock = $this->createMock(ConfigurationService::class);
178 $configurationServiceMock->expects(self::any())->method(
179 'getAllowedValuesForPropertyCollectionPropertyFromFormEditorSetup'
181 [$validationDto,
true, $allowedValues],
182 [$validationDto,
false, $untranslatedAllowedValues],
184 $configurationServiceMock->expects(self::any())->method(
'getAllBackendTranslationsForTranslationKeys')->willReturn($allPossibleAllowedValuesTranslations);
185 $validatorMock->expects(self::any())->method(
'getConfigurationService')->willReturn($configurationServiceMock);
189 $validatorMock->_call(
'validatePropertyCollectionPropertyValue', $input, $validationDto);
193 self::assertFalse($failed);