@@ -115,6 +115,7 @@ public function test_getSubscribedEvents()
115115 'core.posting_modify_template_vars ' ,
116116 'core.posting_modify_submit_post_before ' ,
117117 'core.posting_modify_submit_post_after ' ,
118+ 'core.mcp_change_poster_after ' ,
118119 ), array_keys (\phpbb \ideas \event \listener::getSubscribedEvents ()));
119120 }
120121
@@ -674,6 +675,57 @@ public function test_submit_idea($mode, $forum_id, $topic_id, $approved, $succes
674675
675676 $ listener ->submit_idea_after ($ event );
676677 }
678+
679+ /**
680+ * Data set for change_idea_author
681+ *
682+ * @return array Array of test data
683+ */
684+ public function change_idea_author_data ()
685+ {
686+ return [
687+ [2 , 1 , 1 , 2 , true ], // Valid: ideas forum, different authors
688+ [1 , 1 , 1 , 2 , false ], // Invalid: not ideas forum
689+ [2 , 1 , 1 , 1 , false ], // Invalid: same author
690+ ];
691+ }
692+
693+ /**
694+ * Test the change_idea_author event
695+ *
696+ * @dataProvider change_idea_author_data
697+ */
698+ public function test_change_idea_author ($ forum_id , $ topic_id , $ old_author_id , $ new_author_id , $ should_update )
699+ {
700+ $ listener = $ this ->get_listener ();
701+
702+ $ event = new \phpbb \event \data ([
703+ 'post_info ' => [
704+ 'forum_id ' => $ forum_id ,
705+ 'topic_id ' => $ topic_id ,
706+ 'poster_id ' => $ old_author_id ,
707+ ],
708+ 'userdata ' => [
709+ 'user_id ' => $ new_author_id ,
710+ ],
711+ ]);
712+
713+ $ idea_data = [
714+ 'idea_id ' => 1 ,
715+ 'idea_author ' => $ old_author_id ,
716+ ];
717+
718+ $ this ->idea ->expects ($ should_update ? self ::once () : self ::never ())
719+ ->method ('get_idea_by_topic_id ' )
720+ ->with ($ topic_id )
721+ ->willReturn ($ idea_data );
722+
723+ $ this ->idea ->expects ($ should_update ? self ::once () : self ::never ())
724+ ->method ('set_author ' )
725+ ->with (1 , $ new_author_id );
726+
727+ $ listener ->change_idea_author ($ event );
728+ }
677729}
678730
679731/**
0 commit comments