|
93 | 93 | * - is done when a user of the dedicated group is assigned to the ticket : @see self::testOlaTtoIsCompleteWhenTicketIsAssignedToUserInDedicatedGroup() |
94 | 94 | * - is not done when a non dedicated group is assigned to the ticket : @see self::testOlaIsNotCompleteWhenTicketIsAssignedToNonDedicatedGroup() |
95 | 95 | * - is not done when a user not in the dedicated group is assigned to the ticket : @see self::testOlaTtoIsNotCompleteWhenTicketIsAssignedToUserNotInDedicatedGroup() |
| 96 | + * - is not done when the group is added and the ola added by rule : @see self::testOlaTtoIsNotCompleteWhenTicketIsAssignedToDedicatedGroupAndOlaAddedByRule() |
| 97 | + * - is done when a group associated to ola is removed from ticket assigned group : @see self::testOlaTtoIsCompleteWhenGroupAssociatedToOlaIsRemovedFromTicketAssignedGroup() |
| 98 | + * - is done when ticket is "taken into account" (add task, add followup) by a user of the ola group : @todoseb - d'abord vérifier à quoi correspond taken_into_account(_delay) |
| 99 | + * - is not done when ticket is updated(add task, add followup) by a user not in the ola group : @todoseb - d'abord vérifier à quoi correspond taken_into_account(_delay) |
| 100 | + * @todoseb voir quels tests sont à répliquer pour les TTR |
96 | 101 | * |
97 | 102 | * - delay : |
98 | 103 | * - due time is not delayed if the ticket status is WAITING and ticket is not assigned to group: @see self::testOlaTTODueTimeIsNotDelayedWhileTicketStatusIsWaitingAndNotAssignedToOlaGroup() |
@@ -656,6 +661,95 @@ public function testOlaTtoIsNotCompleteWhenTicketIsAssignedToUserNotInDedicatedG |
656 | 661 | $this->assertEquals(0, $ola_data['end_time'], 'End time should be set to the moment ticket is assigned to a user of the dedicated group.'); |
657 | 662 | } |
658 | 663 |
|
| 664 | + /** |
| 665 | + * - un ticket est ajouté dans l'entité Delpharm |
| 666 | + * - cela déclenche la règle Affectation SLA par defaut : ajout du groupe G_servicedesk + ajout de 2 SLA |
| 667 | + * - au besoin, vous faites une escalade : l'assignation du ticket au groupe G_N1 |
| 668 | + * - cela enclenche la règle OLA N1 : ajout de 2 OLA : OLA_N1_TTO & OLA_N1_TTR (le premier problème est rencontré à ce niveau car l'ola est directement considére comme accompli puisque le groupe associé à l'ola est assigné au ticket). |
| 669 | + * - la même chose se produit si on a ensuite une affectation du ticket au groupe N2. |
| 670 | + */ |
| 671 | + public function testOlaTtoIsNotCompleteWhenTicketIsAssignedToDedicatedGroupAndOlaAddedByRule(): void |
| 672 | + { |
| 673 | + $this->login(); |
| 674 | + $g_desk = $this->createItem(Group::class, ['name' => 'G_desk', 'is_assign' => 1]); |
| 675 | + $g_n1 = $this->createItem(Group::class, ['name' => 'N1', 'is_assign' => 1]); |
| 676 | + $ola_tto_n1 = $this->createOLA(ola_type: SLM::TTO, group: $g_n1)['ola']; |
| 677 | + |
| 678 | + // rule : when ticket is assigned to group N1 -> add OLA N1 TTO to ticket |
| 679 | + $rule_builder = new RuleBuilder('add ola n1 tto'); |
| 680 | + $rule_builder->addCriteria('_groups_id_assign', Rule::PATTERN_IS, $g_n1->getID()); |
| 681 | + $rule_builder->addAction('append', 'olas_id', $ola_tto_n1->getID()); |
| 682 | + $this->createRule($rule_builder); |
| 683 | + |
| 684 | + |
| 685 | + // Ticket assigned to group g_desk |
| 686 | + $ticket = $this->createTicket([ |
| 687 | + '_groups_id_assign' => $g_desk->getID(), |
| 688 | + ]); |
| 689 | + |
| 690 | + // update ticket : assign to group N1 |
| 691 | + $ticket = $this->updateItem( |
| 692 | + Ticket::class, |
| 693 | + $ticket->getID(), |
| 694 | + [ |
| 695 | + '_groups_id_assign' => $g_n1->getID(), |
| 696 | + ] |
| 697 | + ); |
| 698 | + // check rule has processed : OLA TTO is added to ticket |
| 699 | + $fetched_ola_data = $ticket->getOlasTTOData()[0] ?? throw new \Exception('OLA TTO should be added to ticket by rule'); |
| 700 | + assert($fetched_ola_data['olas_id'] === $ola_tto_n1->getID(), 'OLA TTO should be added to ticket by rule'); |
| 701 | + |
| 702 | + // assert OLA TTO is not complete |
| 703 | + $this->assertNull($fetched_ola_data['end_time']); |
| 704 | + } |
| 705 | + |
| 706 | + public function testOlaTtoIsCompleteWhenGroupAssociatedToOlaIsRemovedFromTicketAssignedGroup(): void |
| 707 | + { |
| 708 | + // create ticket with OLA TTO not completed - copy from testOlaTtoIsNotCompleteWhenTicketIsAssignedToDedicatedGroupAndOlaAddedByRule |
| 709 | + $this->login(); |
| 710 | + $g_desk = $this->createItem(Group::class, ['name' => 'G_desk', 'is_assign' => 1]); |
| 711 | + $g_n1 = $this->createItem(Group::class, ['name' => 'N1', 'is_assign' => 1]); |
| 712 | + $ola_tto_n1 = $this->createOLA(ola_type: SLM::TTO, group: $g_n1)['ola']; |
| 713 | + |
| 714 | + // rule : when ticket is assigned to group N1 -> add OLA N1 TTO to ticket |
| 715 | + $rule_builder = new RuleBuilder('add ola n1 tto'); |
| 716 | + $rule_builder->addCriteria('_groups_id_assign', Rule::PATTERN_IS, $g_n1->getID()); |
| 717 | + $rule_builder->addAction('append', 'olas_id', $ola_tto_n1->getID()); |
| 718 | + $this->createRule($rule_builder); |
| 719 | + |
| 720 | + |
| 721 | + // Ticket assigned to group g_desk |
| 722 | + $ticket = $this->createTicket([ |
| 723 | + '_groups_id_assign' => $g_desk->getID(), |
| 724 | + ]); |
| 725 | + |
| 726 | + // update ticket : assign to group N1 |
| 727 | + $ticket = $this->updateItem( |
| 728 | + Ticket::class, |
| 729 | + $ticket->getID(), |
| 730 | + [ |
| 731 | + '_groups_id_assign' => $g_n1->getID(), |
| 732 | + ] |
| 733 | + ); |
| 734 | + // check rule has processed : OLA TTO is added to ticket |
| 735 | + $fetched_ola_data = $ticket->getOlasTTOData()[0] ?? throw new \Exception('OLA TTO should be added to ticket by rule'); |
| 736 | + assert($fetched_ola_data['olas_id'] === $ola_tto_n1->getID(), 'OLA TTO should be added to ticket by rule'); |
| 737 | + |
| 738 | + // check OLA TTO is not complete |
| 739 | + assert(null == $fetched_ola_data['end_time']); |
| 740 | + |
| 741 | + // act : remove group associated to OLA TTO from ticket assigned groups, maybe there is a cleaner way to do this |
| 742 | + $gt = new \Group_Ticket(); |
| 743 | + assert(true === $gt->deleteByCriteria(['tickets_id' => $ticket->getID(), 'groups_id' => $g_n1->getID()])); |
| 744 | + throw new \Exception('mise à jour des olas pas lancée dans le deleteByCriteria, hors on a besoin de mettre à jour item_olas '); |
| 745 | + |
| 746 | + $ticket = $this->reloadItem($ticket); |
| 747 | + assert(false === $ticket->isGroup(CommonITILActor::ASSIGN, $g_n1->getID()), 'Group N1 should not be assigned to ticket anymore'); |
| 748 | + |
| 749 | + // assert OLA TTO is now complete |
| 750 | + $this->assertNotNull($fetched_ola_data['end_time']); |
| 751 | + } |
| 752 | + |
659 | 753 | public function testOlaTTODueTimeIsNotDelayedWhileTicketStatusIsWaitingAndNotAssignedToOlaGroup(): void |
660 | 754 | { |
661 | 755 | $this->login(); |
|
0 commit comments