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

@@ -98,17 +98,36 @@ class AccompanyingPeriodWorkEvaluationDocumentWorkflowHandler implements EntityW
public function getSuggestedUsers(EntityWorkflow $entityWorkflow): array
{
$suggestedUsers = $entityWorkflow->getUsersInvolved();
$related = $this->getRelatedEntity($entityWorkflow);
$referrer = $this->getRelatedEntity($entityWorkflow)
->getAccompanyingPeriodWorkEvaluation()
if (null === $related) {
return [];
}
$users = [];
if (null !== $referrer = $related->getAccompanyingPeriodWorkEvaluation()
->getAccompanyingPeriodWork()
->getAccompanyingPeriod()
->getUser();
->getUser()
) {
$users[] = $referrer;
}
$suggestedUsers[spl_object_hash($referrer)] = $referrer;
foreach ($related->getAccompanyingPeriodWorkEvaluation()
->getAccompanyingPeriodWork()
->getReferrersHistoryCurrent() as $referrerHistory
) {
$users[] = $referrerHistory->getUser();
}
return $suggestedUsers;
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