mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
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:
@@ -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
|
||||
|
Reference in New Issue
Block a user