@@ -4341,6 +4341,107 @@ public function testResponsesAfterMerge(): void
43414341 ]));
43424342 }
43434343
4344+ /**
4345+ * When two tickets have a SON_OF link but the child is NOT deleted (not actually merged),
4346+ * responses added to the child must NOT be propagated to the parent.
4347+ */
4348+ public function testResponsesNotPropagatedWhenChildNotDeleted (): void
4349+ {
4350+ $ this ->login ();
4351+ $ _SESSION ['glpiactiveprofile ' ]['interface ' ] = '' ;
4352+ $ this ->setEntity ('Root entity ' , true );
4353+
4354+ $ parent_id = $ this ->createItem (
4355+ Ticket::class,
4356+ [
4357+ 'name ' => 'Parent ticket ' ,
4358+ 'content ' => 'Parent ticket ' ,
4359+ 'entities_id ' => 0 ,
4360+ 'status ' => CommonITILObject::INCOMING ,
4361+ ]
4362+ )->getID ();
4363+
4364+ $ child_id = $ this ->createItem (
4365+ Ticket::class,
4366+ [
4367+ 'name ' => 'Child ticket ' ,
4368+ 'content ' => 'Child ticket ' ,
4369+ 'entities_id ' => 0 ,
4370+ 'status ' => CommonITILObject::INCOMING ,
4371+ ]
4372+ )->getID ();
4373+
4374+ // Create a SON_OF link WITHOUT merging (child is not deleted)
4375+ $ this ->createItem (
4376+ \Ticket_Ticket::class,
4377+ [
4378+ 'link ' => \Ticket_Ticket::SON_OF ,
4379+ 'tickets_id_1 ' => $ child_id ,
4380+ 'tickets_id_2 ' => $ parent_id ,
4381+ ]
4382+ );
4383+
4384+ // Add a followup to the child ticket
4385+ $ followup = $ this ->createItem (
4386+ ITILFollowup::class,
4387+ [
4388+ 'itemtype ' => 'Ticket ' ,
4389+ 'items_id ' => $ child_id ,
4390+ 'content ' => 'Followup on non-deleted child ' ,
4391+ ]
4392+ );
4393+
4394+ // The followup must NOT have been copied to the parent
4395+ $ this ->assertEmpty ($ followup ->find ([
4396+ 'itemtype ' => 'Ticket ' ,
4397+ 'items_id ' => $ parent_id ,
4398+ 'sourceitems_id ' => $ child_id ,
4399+ ]));
4400+
4401+ // Add a task to the child ticket
4402+ $ task = $ this ->createItem (
4403+ TicketTask::class,
4404+ [
4405+ 'tickets_id ' => $ child_id ,
4406+ 'content ' => 'Task on non-deleted child ' ,
4407+ ]
4408+ );
4409+
4410+ // The task must NOT have been copied to the parent
4411+ $ this ->assertEmpty ($ task ->find ([
4412+ 'tickets_id ' => $ parent_id ,
4413+ 'sourceitems_id ' => $ child_id ,
4414+ ]));
4415+
4416+ // Add a document to the child ticket
4417+ $ documents_id = $ this ->createItem (
4418+ \Document::class,
4419+ [
4420+ 'name ' => 'Child ticket document ' ,
4421+ 'filename ' => 'doc.xls ' ,
4422+ 'users_id ' => Session::getLoginUserID (),
4423+ ]
4424+ )->getID ();
4425+
4426+ $ document_item = $ this ->createItem (
4427+ \Document_Item::class,
4428+ [
4429+ 'itemtype ' => 'Ticket ' ,
4430+ 'items_id ' => $ child_id ,
4431+ 'documents_id ' => $ documents_id ,
4432+ 'entities_id ' => '0 ' ,
4433+ 'is_recursive ' => 0 ,
4434+ ]
4435+ );
4436+
4437+ // The document must NOT have been copied to the parent
4438+ $ this ->assertEmpty ($ document_item ->find ([
4439+ 'itemtype ' => 'Ticket ' ,
4440+ 'items_id ' => $ parent_id ,
4441+ 'documents_id ' => $ documents_id ,
4442+ ]));
4443+ }
4444+
43444445 public function testKeepScreenshotsOnFormReload ()
43454446 {
43464447 //login to get session
0 commit comments