@@ -168,6 +168,68 @@ public function test_show_post_buttons($forum_id, $post_id, $first_post_id, $pos
168168 $ this ->assertTrue ($ event ['post_row ' ]['U_INFO ' ]);
169169 }
170170
171+ /**
172+ * Data set for adjust_quickmod_tools
173+ *
174+ * @return array Array of test data
175+ */
176+ public function adjust_quickmod_tools_data ()
177+ {
178+ $ quickmod_array = [
179+ 'lock ' => [1 => true ],
180+ 'unlock ' => [1 => true ],
181+ 'delete_topic ' => [1 => true ],
182+ 'restore_topic ' => [1 => true ],
183+ 'move ' => [1 => true ],
184+ 'split ' => [1 => true ],
185+ 'merge ' => [1 => true ],
186+ 'merge_topic ' => [1 => true ],
187+ 'fork ' => [1 => true ],
188+ 'make_normal ' => [1 => true ],
189+ 'make_sticky ' => [1 => true ],
190+ 'make_announce ' => [1 => true ],
191+ 'make_global ' => [1 => true ],
192+ ];
193+
194+ return [
195+ [2 , $ quickmod_array , false ], // Valid
196+ [1 , $ quickmod_array , true ], // Invalid forum
197+ ];
198+ }
199+
200+ /**
201+ * Test the adjust_quickmod_tools event
202+ *
203+ * @dataProvider adjust_quickmod_tools_data
204+ */
205+ public function test_adjust_quickmod_tools ($ forum_id , $ quickmod_array , $ expected )
206+ {
207+ $ listener = $ this ->get_listener ();
208+
209+ $ event = new \phpbb \event \data ([
210+ 'forum_id ' => $ forum_id ,
211+ 'quickmod_array ' => $ quickmod_array ,
212+ ]);
213+
214+ $ listener ->adjust_quickmod_tools ($ event );
215+
216+ $ this ->assertEquals ($ expected , $ event ['quickmod_array ' ]['delete_topic ' ][1 ]);
217+ $ this ->assertEquals ($ expected , $ event ['quickmod_array ' ]['restore_topic ' ][1 ]);
218+ $ this ->assertEquals ($ expected , $ event ['quickmod_array ' ]['make_normal ' ][1 ]);
219+ $ this ->assertEquals ($ expected , $ event ['quickmod_array ' ]['make_sticky ' ][1 ]);
220+ $ this ->assertEquals ($ expected , $ event ['quickmod_array ' ]['make_announce ' ][1 ]);
221+ $ this ->assertEquals ($ expected , $ event ['quickmod_array ' ]['make_global ' ][1 ]);
222+
223+ // These should always be true since we're not changing them
224+ $ this ->assertTrue ($ event ['quickmod_array ' ]['lock ' ][1 ]);
225+ $ this ->assertTrue ($ event ['quickmod_array ' ]['unlock ' ][1 ]);
226+ $ this ->assertTrue ($ event ['quickmod_array ' ]['move ' ][1 ]);
227+ $ this ->assertTrue ($ event ['quickmod_array ' ]['split ' ][1 ]);
228+ $ this ->assertTrue ($ event ['quickmod_array ' ]['merge ' ][1 ]);
229+ $ this ->assertTrue ($ event ['quickmod_array ' ]['merge_topic ' ][1 ]);
230+ $ this ->assertTrue ($ event ['quickmod_array ' ]['fork ' ][1 ]);
231+ }
232+
171233 /**
172234 * Data set for test_viewonline
173235 *
@@ -381,6 +443,41 @@ public function test_edit_idea_title($data, $expected)
381443 $ listener ->edit_idea_title ($ event );
382444 }
383445
446+ /**
447+ * Test data for test_ideas_forum_redirect
448+ */
449+ public function ideas_forum_redirect_data ()
450+ {
451+ return [
452+ [2 , '$url ' , true ],
453+ [4 , '$url ' , false ],
454+ ];
455+ }
456+
457+ /**
458+ * Test the ideas_forum_redirect() method
459+ *
460+ * @dataProvider ideas_forum_redirect_data
461+ */
462+ public function test_ideas_forum_redirect ($ forum_id , $ url , $ expected )
463+ {
464+ if ($ expected )
465+ {
466+ $ this ->setExpectedTriggerError (E_USER_NOTICE , "Redirected to $ url " );
467+ }
468+ $ this ->helper ->expects ($ expected ? $ this ->once () : $ this ->never ())
469+ ->method ('route ' )
470+ ->willReturn ($ url );
471+
472+ $ listener = $ this ->get_listener ();
473+
474+ $ event = new \phpbb \event \data ([
475+ 'forum_id ' => $ forum_id ,
476+ ]);
477+
478+ $ listener ->ideas_forum_redirect ($ event );
479+ }
480+
384481 public function submit_idea_data ()
385482 {
386483 return [
@@ -475,9 +572,20 @@ public function test_submit_idea($mode, $forum_id, $topic_id, $approved, $succes
475572 }
476573}
477574
575+ /**
576+ * Mock redirect()
577+ * Note: use the same namespace as the ideas
578+ *
579+ * @return void
580+ */
581+ function redirect ($ url )
582+ {
583+ trigger_error ("Redirected to $ url " , E_USER_NOTICE );
584+ }
585+
478586/**
479587 * Mock meta_refresh()
480- * Note: use the same namespace as the idea_controller
588+ * Note: use the same namespace as the ideas
481589 *
482590 * @return void
483591 */
0 commit comments