Skip to content

Commit 7807401

Browse files
committed
cleanup tests : write a spec bloc.
1 parent 90abf77 commit 7807401

1 file changed

Lines changed: 46 additions & 18 deletions

File tree

tests/functional/OLATest.php

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,36 @@
5656
use User;
5757

5858
/**
59-
* Test Plan / Spec
59+
* OLA functional specifications (extracted from test plan below)
60+
*
61+
* - multiple OLA can be associated to a ticket (no more just a single tto and a single ttr)
62+
* - ola due dates cannot be set manually anymore in a ticket
63+
* - the same ola can be associated multiple times to a ticket, if one is completed.
64+
* - old form params are still supported (olas_id_tto, olas_id_ttr)
65+
* - ola must be associated with a group (if the group has the ability to be assigned to a ticket)
66+
* - ola previously created (without group) can be associated to tickets
67+
* - ola can be associated to ticket by rule and form at the same time
68+
* - completion :
69+
* - tto :
70+
* - when ticket is "taken into account" (add task, add followup) by a user of the ola group
71+
* - when a user of the dedicated group assign itself (or it's group) to the ticket.
72+
* - when a group associated to ola is removed from ticket assigned group
73+
* - ttr :
74+
* - when the ticket is closed or solved
75+
* - when a group associated to ola is removed from ticket assigned group
76+
* - due time delaying :
77+
* - ttr : when the ticket status is WAITING
78+
* - tto : when the ticket status is WAITING and ticket is not assigned to group
79+
* - due_time is not updated on ticket's date update
80+
* - ticket is late if :
81+
* - end_time is defined and > due_time
82+
* - end_time is not defined & due_time is passed
83+
* - ticket status is not WAITING
84+
*/
85+
86+
/**
87+
* Test Plan
88+
*
6089
* - ola waiting_start is set to current time on ticket creation with waiting status : @see self::testOlaWaitingStartIsSetOnTicketCreationWithWaitingStatus()
6190
* - ola data are retrieved : @see self::testGetOLAData()
6291
* - ola can be associated and deassociate to a ticket :
@@ -89,10 +118,9 @@
89118
* - on ticket update : @see self::testInitialOlaTtoValuesOnUpdate()
90119
*
91120
* - completion :
92-
* - is done when the dedicated group is assigned to the ticket : @see self::testOlaTtoIsCompleteWhenTicketIsAssignedToDedicatedGroup()
93-
* - is done when a user of the dedicated group is assigned to the ticket by a user of the ola group : @see self::testOlaTtoIsCompleteWhenTicketIsAssignedToUserInDedicatedGroupByUserOfOlaGroup()
121+
* - is done when a user of the dedicated group is assigned to the ticket by a user of the ola group : @see self::testOlaTtoIsCompleteWhenTicketIsAssignedToUserInDedicatedGroupByUserOfOlaGroup()
94122
* - is not done when a user of the dedicated group is assigned to the ticket by foreign user of the ola group : @see self::testOlaTtoIsCompleteWhenTicketIsAssignedToUserInDedicatedGroupByUserOfAnotherGroup()
95-
* - is not done when a non dedicated group is assigned to the ticket : @see self::testOlaIsNotCompleteWhenTicketIsAssignedToNonDedicatedGroup()
123+
* - is not done when a non-dedicated group is assigned to the ticket : @see self::testOlaIsNotCompleteWhenTicketIsAssignedToNonDedicatedGroup()
96124
* - is not done when a user not in the dedicated group is assigned to the ticket : @see self::testOlaTtoIsNotCompleteWhenTicketIsAssignedToUserNotInDedicatedGroup()
97125
* - is done when a group associated to ola is removed from ticket assigned group :
98126
* - @see self::testOlaTtoIsCompleteWhenGroupAssociatedToOlaIsRemovedFromTicketAssignedGroup()
@@ -101,12 +129,17 @@
101129
* - @see self::testOlaTtoIsCompleteWhenUserOfGroupAssociatedToOlaTakesTicketIntoAccountWithATask()
102130
* - is not done when ticket is updated(add task, add followup) by a user not in the ola group : @see self::testOlaTtoIsNotCompleteWhenUserNotOfGroupAssociatedToOlaTakesTicketIntoAccount()
103131
*
104-
* - delay (ticket has been paused) : // @todo peut-être qu'on en peut lister ici que les tests qui ont un sens au niveau spec et pas les tests qui sont des vérifications liées (ex les vérifs sur waiting_time sont des implications) -> oui ou plutot faire plusieurs assertions dans le meme test.
132+
* - delay (ticket has been paused) :
105133
* - due time is delayed if the ticket status is WAITING and ticket is not assigned to group: @see self::testOlaTTODueTimeIsDelayedWhileTicketStatusIsWaitingAndNotAssignedToOlaGroup()
106-
* - waiting time is not incremented while the ticket is WAITING and not assigned to ola group @see self::testOlaTTOWaitingTimeIsIncrementedWhileTicketStatusIsWaitingAndNotAssignedToOlaGroup()
134+
* - waiting time is incremented while the ticket is WAITING and not assigned to ola group @see self::testOlaTTOWaitingTimeIsIncrementedWhileTicketStatusIsWaitingAndNotAssignedToOlaGroup()
107135
* - due time is not delayed if the ticket status is WAITING and ticket is assigned to group: @see self::testOlaTTODueTimeIsNotDelayedWhileTicketStatusIsWaitingAndAssignedToOlaGroup()
108136
* - waiting time is not incremented while the ticket is WAITING and assigned to ola group @see self::testOlaTTOWaitingTimeIsNotIncrementedWhileTicketStatusIsWaitingAndAssignedToOlaGroup()
109137
*
138+
* - ticket is late if : (business logic extracted from CommonITILObject::generateSLAOLAComputation())*
139+
* - end_time is defined and > due_time - @see self::testOlaTtoIsLateWhenEndTimeIsAfterDueTime()
140+
* - end_time is not defined & due_time is passed - @see self::testOlaTtoIsLateWhenDueTimeIsPassed()
141+
* - ticket status is not WAITING (1): @see self::testOlaTtoIsNotLateWhenTicketStatusIsNotWaiting()
142+
*
110143
* - ola can be associated by rule and form at the same time @see self::testOlaCanBeAssociatedByRulesAndByForm()
111144
* - due_time is not updated on ticket date update @see self::testOlaTtoDueTimeIsNotUpdatedOnTicketDateUpdate()
112145
*
@@ -124,19 +157,12 @@
124157
* - ttr due time is delayed if the ticket status is WAITING : @see self::testOlaTtrDueTimeIsDelayedWhileTicketStatusIsWaiting
125158
* - ttr waiting time is incremented while the ticket status is WAITING : @see self::testOlaTTRWaitingTimeIsIncrementedWhileTicketStatusIsWaiting()
126159
*
127-
* - ticket is late if : (business logic extracted from CommonITILObject::generateSLAOLAComputation())*
128-
* - tto : (note that takeintoaccountdate is replaced by end_time)
129-
* - end_time is defined and > due_time - @see self::testOlaTtoIsLateWhenEndTimeIsAfterDueTime()
130-
* - end_time is not defined & due_time is passed - @see self::testOlaTtoIsLateWhenDueTimeIsPassed()
131-
* - ticket status is not WAITING (1): @see self::testOlaTtoIsNotLateWhenTicketStatusIsNotWaiting()
132-
*
133-
* - ttr : exactly the same tests as above, duplication to be prepared for future changes
160+
* - ticket is late if : exactly the same tests as for tto (duplication to be prepared for future changes)
134161
* - end_time is defined and > due_time - @see self::testOlaTtrIsLateWhenEndTimeIsAfterDueTime()
135162
* - end_time is not defined & due_time is passed - @see self::testOlaTtrIsLateWhenDueTimeIsPassed()
136163
* - ticket status is not WAITING (1): @see self::testOlaTtrIsNotLateWhenTicketStatusIsNotWating()
137164
*
138165
* - due_time is not updated on ticket date update @see self::testOlaTtrDueTimeIsNotUpdatedOnTicketDateUpdate()
139-
* - when completion is done, the associated group is removed from ticket assignees : not implemented, seems not relevant atm
140166
*/
141167

142168
class OLATest extends DbTestCase
@@ -846,7 +872,7 @@ public function testOlaTtoIsNotCompleteWhenTicketIsAssignedToUserNotInDedicatedG
846872
$ola_data = $ticket->getOlasData()[0];
847873
assert(null === $ola_data['end_time'], 'End time should not be set when OLA is assigned to ticket.');
848874

849-
// act - assign ticket to a user of dedicated group
875+
// act - assign ticket to a user not in the dedicated group
850876
$ticket = $this->updateItem(Ticket::class, $ticket->getID(), ['_users_id_assign' => $user->getID()]);
851877
assert($ticket->isUser(CommonITILActor::ASSIGN, $user->getID()), 'Ticket should be assigned to a user of ola dedicated group.');
852878

@@ -1416,18 +1442,20 @@ public function testOlaTtoIsNotLateWhenTicketStatusIsNotWaiting(): void
14161442
$this->assertFalse((bool) $ola_data['is_late'], 'OLA should not be late when ticket is just created.');
14171443

14181444
// act : wait for ola to be late, set ticket status to WAITING
1419-
$this->updateItem(Ticket::class, $ticket->getID(), ['status' => CommonITILObject::WAITING]);
1420-
14211445
$later = $now
14221446
->add($this->getDefaultOlaTtoDelayInterval())
14231447
->modify('+1 hour') // add 1 hour to ensure end time is after due time
14241448
->format('Y-m-d H:i:s');
14251449
$this->setCurrentTime($later);
14261450
$this->runOlaCron();
14271451

1428-
// assert - check ola is not late
1452+
// assert - check ola is late if ticket is not waiting and not late if ticket is in WAITING status
14291453
$ticket = $this->reloadItem($ticket);
14301454
$ola_data = $ticket->getOlasData()[0];
1455+
$this->assertEquals(1, $ola_data['is_late']);
1456+
1457+
$ticket = $this->updateItem(Ticket::class, $ticket->getID(), ['status' => CommonITILObject::WAITING]);
1458+
$ola_data = $ticket->getOlasData()[0];
14311459
$this->assertEquals(0, $ola_data['is_late'], 'OLA should not be late when ticket is WAITING (even if due time is passed and end time is not set)');
14321460
}
14331461

0 commit comments

Comments
 (0)