Skip to content

Commit

Permalink
Merge pull request mautic#1999 from acquia/MAUT-9959
Browse files Browse the repository at this point in the history
MAUT-9959 : decision's negative path actions aren't triggering as expected
  • Loading branch information
rahuld-dev authored and escopecz committed Nov 26, 2024
1 parent 5d12dbe commit 52d172b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public function groupContactsByDate(Event $event, ArrayCollection $contacts, \Da
*/
public function isContactSpecificExecutionDateRequired(Event $event): bool
{
if (!$this->isTriggerModeInterval($event) || $this->isRestrictedToDailyScheduling($event) || $this->hasTimeRelatedRestrictions($event)) {
if (!$this->isTriggerModeInterval($event) || $this->hasTimeRelatedRestrictions($event)
|| $this->isRestrictedToDailyScheduling($event) || $this->isNegativePath($event)) {
return false;
}

Expand All @@ -161,6 +162,15 @@ private function hasTimeRelatedRestrictions(Event $event): bool
&& empty($event->getTriggerRestrictedDaysOfWeek());
}

private function isNegativePath(Event $event): bool
{
if ($event->getParent()) {
return Event::TYPE_DECISION === $event->getParent()->getEventType() && Event::TYPE_ACTION === $event->getEventType() && Event::PATH_INACTION === $event->getDecisionPath();
}

return false;
}

/**
* @return \DateTimeInterface
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,34 @@ public function testValidateExecutionDateTimeWhenForExactHour(): void

Assert::assertEquals($expectedDateTime->format('Y-m-d H:i'), $interval->validateExecutionDateTime($log, $compareFromDateTime)->format('Y-m-d H:i'));
}

public function testIsContactSpecificExecutionDateRequiredShouldReturnFalseForNegativePathAction(): void
{
$parentEvent = $this->createMock(Event::class);
$parentEvent->method('getEventType')
->willReturn(Event::TYPE_DECISION);
$event = $this->createMock(Event::class);
$event->method('getId')
->willReturn(1);
$event->method('getTriggerMode')
->willReturn(Event::TRIGGER_MODE_INTERVAL);
$event->method('getTriggerIntervalUnit')
->willReturn('i');
$event->method('getTriggerInterval')
->willReturn(5);
$event->method('getDecisionPath')
->willReturn(Event::PATH_INACTION);
$event->method('getEventType')
->willReturn(Event::TYPE_ACTION);
$event->method('getTriggerHour')
->willReturn(new \DateTime('now'));
$event->method('getTriggerRestrictedDaysOfWeek')
->willReturn([]);
$event->method('getParent')
->willReturn($parentEvent);

$interval = $this->getInterval();

Assert::assertFalse($interval->isContactSpecificExecutionDateRequired($event));
}
}

0 comments on commit 52d172b

Please sign in to comment.