File tree Expand file tree Collapse file tree
tests/functional/Glpi/Form/Destination/CommonITILField Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,6 +239,9 @@ private function checkOLATTRFieldConfiguration(
239239 // Insert config
240240 $ destinations = $ form ->getDestinations ();
241241 $ this ->assertCount (1 , $ destinations );
242+ if ($ expected_olas_ttr_id !== 0 && countElementsInTable (OLA ::getTable (), ['id ' => $ expected_olas_ttr_id ]) !== 1 ) {
243+ throw new \Exception ("Expected OLA TTR with ID $ $ expected_olas_ttr_id not found in database. Wrong data preparation. " );
244+ }
242245 $ destination = current ($ destinations );
243246 $ this ->updateItem (
244247 $ destination ::getType (),
@@ -261,13 +264,11 @@ private function checkOLATTRFieldConfiguration(
261264 $ ticket = current ($ created_items );
262265
263266 // Check ola_id_ttr field
264- $ ticket_ttr_data = $ ticket ->getOlasTTRData ()[0 ] ?? throw new \Exception ('Ola TTR not found ' );
265- $ this ->assertEquals ($ expected_olas_ttr_id , $ ticket_ttr_data ['olas_id ' ]);
266-
267- // Check internal_time_to_resolve field
268- if ($ expected_ttr_date !== null ) {
269- $ this ->assertEquals ($ expected_ttr_date , $ ticket ->fields ['internal_time_to_resolve ' ]);
270- }
267+ $ ticket_ola_ttr_id = $ expected_olas_ttr_id
268+ ? ($ ticket ->getOlasTTRData ()[0 ])['olas_id ' ] ?? throw new \Exception ('Ola TTR not found ' )
269+ : 0
270+ ;
271+ $ this ->assertEquals ($ expected_olas_ttr_id , $ ticket_ola_ttr_id , "The created ticket should have the expected OLA TTR ID " );
271272
272273 // Return the created ticket to be able to check other fields
273274 return $ ticket ;
You can’t perform that action at this time.
0 commit comments