Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/7.5' into 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Jul 21, 2021
2 parents 7d7315e + ce61bd9 commit 4f1d28e
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eZ/Publish/Core/FieldType/Selection/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function validate(FieldDefinition $fieldDefinition, SPIValue $fieldValue)
return array_keys($languageOptionIndexes);
}, $fieldSettings['multilingualOptions']);

$possibleOptionIndexes = call_user_func_array('array_merge', $possibleOptionIndexesByLanguage);
$possibleOptionIndexes = array_merge(...array_values($possibleOptionIndexesByLanguage));

foreach ($fieldValue->selection as $optionIndex) {
if (!in_array($optionIndex, $possibleOptionIndexes)) {
Expand Down
49 changes: 49 additions & 0 deletions eZ/Publish/Core/FieldType/Tests/SelectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,32 @@ public function provideValidDataForValidate()
],
new SelectionValue(),
],
[
[
'fieldSettings' => [
'isMultiple' => false,
'options' => [0 => 1, 1 => 2],
'multilingualOptions' => [
'en_GB' => [0 => 1, 1 => 2],
'de_DE' => [0 => 1, 1 => 2],
],
],
],
new SelectionValue([1]),
],
[
[
'fieldSettings' => [
'isMultiple' => false,
'options' => [0 => 1, 1 => 2],
'multilingualOptions' => [
'en_GB' => [0 => 1, 1 => 2],
'de_DE' => [0 => 1],
],
],
],
new SelectionValue([1]),
],
];
}

Expand Down Expand Up @@ -586,6 +612,29 @@ public function provideInvalidDataForValidate()
),
],
],
[
[
'fieldSettings' => [
'isMultiple' => false,
'options' => [0 => 1, 1 => 2],
'multilingualOptions' => [
'en_GB' => [0 => 1, 1 => 2],
'de_DE' => [0 => 1],
],
],
],
new SelectionValue([3]),
[
new ValidationError(
'Option with index %index% does not exist in the field definition.',
null,
[
'%index%' => 3,
],
'selection'
),
],
],
];
}
}

0 comments on commit 4f1d28e

Please sign in to comment.