Add and update test handlers for suggested users retrieval

Introduced new test files for workflow handlers and adjusted existing `getSuggestedUsers` methods to handle related entity checks and duplicates removal. Also, modified repos to align with test dependencies.
This commit is contained in:
2024-10-22 23:15:03 +02:00
parent 418794e586
commit c877076429
10 changed files with 410 additions and 29 deletions

View File

@@ -87,17 +87,32 @@ readonly class AccompanyingPeriodWorkWorkflowHandler implements EntityWorkflowHa
public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array
{
$suggestedUsers = $entityWorkflow->getUsersInvolved();
$related = $this->getRelatedEntity($entityWorkflow);
$referrer = $this->getRelatedEntity($entityWorkflow)
->getAccompanyingPeriod()
->getUser();
if (null !== $referrer) {
$suggestedUsers[spl_object_hash($referrer)] = $referrer;
if (null === $related) {
return [];
}
return $suggestedUsers;
$users = [];
if (null !== $referrer = $related->getAccompanyingPeriod()
->getUser()
) {
$users[] = $referrer;
}
foreach ($related->getReferrersHistoryCurrent() as $referrerHistory
) {
$users[] = $referrerHistory->getUser();
}
return array_values(
// filter objects to remove duplicates
array_filter(
$users,
fn ($o, $k) => array_search($o, $users, true) === $k,
ARRAY_FILTER_USE_BOTH
)
);
}
public function getTemplate(EntityWorkflow $entityWorkflow, array $options = []): string