N°7157 - Add unit test for subscription mechanism and refactor repository methods

This commit is contained in:
Molkobain
2024-03-08 12:22:16 +01:00
parent 509df0939e
commit 2aa1385958
4 changed files with 222 additions and 47 deletions

View File

@@ -65,7 +65,7 @@ class NotificationsService {
public function RegisterSubscription(Trigger $oTrigger, ActionNotification $oActionNotification, Contact $oRecipient): void
{
// Check if the user is already subscribed to the action notification
$oSubscribedActionsNotificationsSet = NotificationsRepository::GetInstance()->SearchSubscriptionByTriggerContactAndAction($oTrigger->GetKey(), $oRecipient->GetKey(), $oActionNotification->GetKey());
$oSubscribedActionsNotificationsSet = NotificationsRepository::GetInstance()->SearchSubscriptionsByTriggerContactAndAction($oTrigger->GetKey(), $oActionNotification->GetKey(), $oRecipient->GetKey());
if ($oSubscribedActionsNotificationsSet->Count() === 0) {
// Create a new subscription
$oSubscribedActionsNotifications = new lnkActionNotificationToContact();
@@ -104,7 +104,7 @@ class NotificationsService {
return true;
}
// Check if the user is already subscribed to the action notification
$oSubscribedActionsNotificationsSet = NotificationsRepository::GetInstance()->SearchSubscriptionByTriggerContactAndAction($oTrigger->GetKey(), $oRecipient->GetKey(), $oActionNotification->GetKey());
$oSubscribedActionsNotificationsSet = NotificationsRepository::GetInstance()->SearchSubscriptionsByTriggerContactAndAction($oTrigger->GetKey(), $oActionNotification->GetKey(), $oRecipient->GetKey());
if ($oSubscribedActionsNotificationsSet->Count() === 0) {
return true;
}