|
42 | 42 | use NotificationEventMailing; |
43 | 43 | use NotificationTargetCommonITILObject; |
44 | 44 | use PHPUnit\Framework\Attributes\DataProvider; |
| 45 | +use QueuedNotification; |
45 | 46 | use Rule; |
46 | 47 | use RuleCommonITILObject; |
47 | 48 | use RuntimeException; |
@@ -1624,4 +1625,40 @@ public function testNotificationValidatorSubstitutes() |
1624 | 1625 | // Substitute timerange expired |
1625 | 1626 | $this->assertEmpty($notification_target->target); |
1626 | 1627 | } |
| 1628 | + |
| 1629 | + public function testValidationAnswerNotification(): void |
| 1630 | + { |
| 1631 | + global $CFG_GLPI; |
| 1632 | + |
| 1633 | + $this->login(); |
| 1634 | + $itil = $this->createItem($this->getITILClassname(), [ |
| 1635 | + 'name' => 'Test Notification Recipients', |
| 1636 | + 'content' => 'Test Notification Recipients', |
| 1637 | + ]); |
| 1638 | + $validation = $this->createItem($this->getValidationClassname(), [ |
| 1639 | + $itil::getForeignKeyField() => $itil->getID(), |
| 1640 | + 'itemtype_target' => 'User', |
| 1641 | + 'items_id_target' => $_SESSION['glpiID'], |
| 1642 | + ]); |
| 1643 | + $queued_notification = new QueuedNotification(); |
| 1644 | + |
| 1645 | + $CFG_GLPI["use_notifications"] = true; |
| 1646 | + $CFG_GLPI['notifications_mailing'] = true; |
| 1647 | + |
| 1648 | + $this->assertEquals(0, countElementsInTable($queued_notification::getTable(), ['event' => 'validation_answer'])); |
| 1649 | + |
| 1650 | + // Updating the submission comment should not trigger the validation_answer notification |
| 1651 | + $validation->update([ |
| 1652 | + 'id' => $validation->getID(), |
| 1653 | + 'comment_submission' => 'This is a comment.', |
| 1654 | + ]); |
| 1655 | + $this->assertEquals(0, countElementsInTable($queued_notification::getTable(), ['event' => 'validation_answer'])); |
| 1656 | + |
| 1657 | + $validation->update([ |
| 1658 | + 'id' => $validation->getID(), |
| 1659 | + 'status' => CommonITILValidation::ACCEPTED, |
| 1660 | + ]); |
| 1661 | + // Administrator + Approver |
| 1662 | + $this->assertEquals(2, countElementsInTable($queued_notification::getTable(), ['event' => 'validation_answer'])); |
| 1663 | + } |
1627 | 1664 | } |
0 commit comments