Skip to content

Commit 071267e

Browse files
committed
wip todo : add missing tests/spec
1 parent 8657522 commit 071267e

3 files changed

Lines changed: 105 additions & 3 deletions

File tree

phpunit/functional/OLATest.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@
9393
* - is done when a user of the dedicated group is assigned to the ticket : @see self::testOlaTtoIsCompleteWhenTicketIsAssignedToUserInDedicatedGroup()
9494
* - is not done when a non dedicated group is assigned to the ticket : @see self::testOlaIsNotCompleteWhenTicketIsAssignedToNonDedicatedGroup()
9595
* - 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
96101
*
97102
* - delay :
98103
* - 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
656661
$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.');
657662
}
658663

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+
659753
public function testOlaTTODueTimeIsNotDelayedWhileTicketStatusIsWaitingAndNotAssignedToOlaGroup(): void
660754
{
661755
$this->login();

src/Item_Ola.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,16 @@ public static function compute(Ticket $ticket, mixed $olas_id): void
165165

166166
// - update end_time
167167
// for TTO, endtime is when the ticket is assigned to the dedicated group.
168+
// - except if update is triggered by a rule
169+
// - except if end_time is already set
170+
// @todoseb refacto en mettant end_time, sur l'ensemble.
171+
// @todoseb traitement de la suppression du groupe de l'OLA (à été présent, ne l'ai plus -> ola tto terminée (idem ttr probablement))
172+
$ola_group_removed = $ticket->haveAGroup(CommonITILActor::ASSIGN, [$ola->fields['groups_id']]);
173+
168174
if ($item_ola_data['ola_type'] === SLM::TTO) {
169-
if ($item_ola_data['end_time'] == null
175+
if (
176+
(!isset($ticket->input['_rule_process']) || !$ticket->input['_rule_process'])
177+
&& $item_ola_data['end_time'] == null
170178
&&
171179
(
172180
$ticket->haveAGroup(CommonITILActor::ASSIGN, [$ola->fields['groups_id']])

src/Ticket.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2766,7 +2766,7 @@ public function rawSearchOptions()
27662766
'name' => __('OLA') . ' ' . __('time to resolve') . ' - ' . __('due time'),
27672767
'massiveaction' => false,
27682768
'datatype' => 'datetime',
2769-
'additionalfields' => ['TABLE.status', 'TABLE.takeintoaccount_delay_stat', 'TABLE.date', 'olas_id', 'waiting_time', 'end_time'],
2769+
'additionalfields' => ['TABLE.status', 'TABLE.takeintoaccount_delay_stat', 'TABLE.date', 'olas_id', 'waiting_time', 'end_time'], // @todoseb champs takeintoaccount_delay_stat surement inutile maintenant
27702770
'joinparams' => [
27712771
'jointype' => 'itemtype_item',
27722772
'condition' => ['NEWTABLE.ola_type' => SLM::TTR,],
@@ -2783,7 +2783,7 @@ public function rawSearchOptions()
27832783
'name' => __('OLA') . ' ' . __('time to resolve') . ' - ' . __('due time + progress'),
27842784
'massiveaction' => false,
27852785
'nosearch' => true,
2786-
'additionalfields' => ['TABLE.status', 'TABLE.takeintoaccount_delay_stat', 'TABLE.date', 'olas_id', 'waiting_time', 'end_time'],
2786+
'additionalfields' => ['TABLE.status', 'TABLE.takeintoaccount_delay_stat', 'TABLE.date', 'olas_id', 'waiting_time', 'end_time'], // @todoseb champs takeintoaccount_delay_stat surement inutile maintenant
27872787
'joinparams' => [
27882788
'jointype' => 'itemtype_item',
27892789
'condition' => ['NEWTABLE.ola_type' => SLM::TTR,],

0 commit comments

Comments
 (0)