Skip to content
Merged
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 @@ -485,7 +485,7 @@ private function mergeGroupMemberUserIdsRaw(array $groupIds, array &$users): voi
$subGroupIds = array_values(array_unique($subGroupIds));
$groupPlaceholders = implode(',', array_fill(0, count($subGroupIds), '?'));
$activeGroups = DB::select(
"SELECT id FROM groups WHERE id IN ($groupPlaceholders) AND status = ?",
"SELECT id FROM `groups` WHERE id IN ($groupPlaceholders) AND status = ?",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

consider to use DB::table if possible

array_merge($subGroupIds, ['ACTIVE'])
);
foreach ($activeGroups as $group) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace Tests\Unit\ProcessMaker\Repositories;

use ProcessMaker\Models\Group;
use ProcessMaker\Models\GroupMember;
use ProcessMaker\Models\ProcessRequest;
use ProcessMaker\Models\User;
use ProcessMaker\Repositories\ProcessExecutionRawRepository;
use Tests\TestCase;

Expand Down Expand Up @@ -34,4 +37,33 @@ public function testGetProcessRequestForResponseRawIncludesDataColumn(): void
$this->assertIsArray($hydrated->data);
$this->assertSame('persisted', $hydrated->data['marker']);
}

public function testRawGroupAssignmentResolvesActiveNestedGroups(): void
{
$user = User::factory()->create(['status' => 'ACTIVE']);
$parentGroup = Group::factory()->create(['status' => 'ACTIVE']);
$childGroup = Group::factory()->create(['status' => 'ACTIVE']);

GroupMember::withoutEvents(function () use ($parentGroup, $childGroup, $user): void {
GroupMember::create([
'group_id' => $parentGroup->id,
'member_id' => $childGroup->id,
'member_type' => Group::class,
]);
GroupMember::create([
'group_id' => $childGroup->id,
'member_id' => $user->id,
'member_type' => User::class,
]);
});

$repository = new ProcessExecutionRawRepository();
$method = new \ReflectionMethod($repository, 'mergeGroupMemberUserIdsRaw');
$method->setAccessible(true);
$users = [];

$method->invokeArgs($repository, [[$parentGroup->id], &$users]);

$this->assertSame([$user->id], array_values($users));
}
}
Loading