Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8980: Fixed getGroupedFields method implementation #77

Open
wants to merge 2 commits into
base: 4.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@ public function __construct(FieldsGroupsList $fieldsGroupsList)

public function getGroupedFields(array $fieldsDataForm): array
{
$fieldsGroups = $this->fieldsGroupsList->getGroups();
$groupedFields = [];

foreach ($fieldsDataForm as $fieldForm) {
/** @var \Ibexa\Contracts\ContentForms\Data\Content\FieldData $fieldData */
$fieldData = $fieldForm->getViewData();
$fieldGroupIdentifier = $this->fieldsGroupsList->getFieldGroup($fieldData->fieldDefinition);
$fieldGroupName = $fieldsGroups[$fieldGroupIdentifier] ?? $this->fieldsGroupsList->getDefaultGroup();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even tho it seems like a bug, not sure we can fix it that way due to bc policy. Otoh, this seems so internal and if only used by that one place (is it tho?) it should be acceptable.
@ibexa/php-dev


$groupedFields[$fieldGroupName][] = $fieldForm->getName();
$groupedFields[$fieldGroupIdentifier][] = $fieldForm->getName();
}

return $groupedFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ public function testGetGroupedFields(): void
->withConsecutive()
->willReturnOnConsecutiveCalls('group_1', 'group_2', 'group_2');

$fieldsGroupsListMock
->expects($this->once())
->method('getGroups')
->willReturn([
'group_1' => 'Group 1',
'group_2' => 'Group 2',
]);

$subject = new GroupedContentFormFieldsProvider($fieldsGroupsListMock);

$form1 = $this->getFormMockWithFieldData(
Expand All @@ -56,10 +48,10 @@ public function testGetGroupedFields(): void
$result = $subject->getGroupedFields([$form1, $form2, $form3]);

$expected = [
'Group 1' => [
'group_1' => [
0 => 'first_field',
],
'Group 2' => [
'group_2' => [
0 => 'second_field',
1 => 'third_field',
],
Expand Down
Loading