@@ -5100,22 +5100,27 @@ public function test_course_get_recent_courses() {
51005100 */
51015101 public function provider_course_modules_pending_deletion () {
51025102 return [
5103- ['forum ' , false , true ],
5104- ['assign ' , false , true ],
5105- ['forum ' , true , false ],
5106- ['assign ' , true , true ],
5103+ 'Non-gradable activity, check all ' => [['forum ' ], 0 , false , true ],
5104+ 'Gradable activity, check all ' => [['assign ' ], 0 , false , true ],
5105+ 'Non-gradable activity, check gradables ' => [['forum ' ], 0 , true , false ],
5106+ 'Gradable activity, check gradables ' => [['assign ' ], 0 , true , true ],
5107+ 'Non-gradable within multiple, check all ' => [['quiz ' , 'forum ' , 'assign ' ], 1 , false , true ],
5108+ 'Non-gradable within multiple, check gradables ' => [['quiz ' , 'forum ' , 'assign ' ], 1 , true , false ],
5109+ 'Gradable within multiple, check all ' => [['quiz ' , 'forum ' , 'assign ' ], 2 , false , true ],
5110+ 'Gradable within multiple, check gradables ' => [['quiz ' , 'forum ' , 'assign ' ], 2 , true , true ],
51075111 ];
51085112 }
51095113
51105114 /**
51115115 * Tests the function course_modules_pending_deletion.
51125116 *
5113- * @param string $module The module we want to test with
5117+ * @param string[] $modules A complete list aff all available modules before deletion
5118+ * @param int $indextodelete The index of the module in the $modules array that we want to test with
51145119 * @param bool $gradable The value to pass to the gradable argument of the course_modules_pending_deletion function
51155120 * @param bool $expected The expected result
51165121 * @dataProvider provider_course_modules_pending_deletion
51175122 */
5118- public function test_course_modules_pending_deletion (string $ module , bool $ gradable , bool $ expected ) {
5123+ public function test_course_modules_pending_deletion (array $ modules , int $ indextodelete , bool $ gradable , bool $ expected ) {
51195124 $ this ->resetAfterTest ();
51205125
51215126 // Ensure recyclebin is enabled.
@@ -5125,9 +5130,12 @@ public function test_course_modules_pending_deletion(string $module, bool $grada
51255130 $ generator = $ this ->getDataGenerator ();
51265131 $ course = $ generator ->create_course ();
51275132
5128- $ moduleinstance = $ generator ->create_module ($ module , array ('course ' => $ course ->id ));
5133+ $ moduleinstances = [];
5134+ foreach ($ modules as $ module ) {
5135+ $ moduleinstances [] = $ generator ->create_module ($ module , array ('course ' => $ course ->id ));
5136+ }
51295137
5130- course_delete_module ($ moduleinstance ->cmid , true ); // Try to delete the instance asynchronously.
5138+ course_delete_module ($ moduleinstances [ $ indextodelete ] ->cmid , true ); // Try to delete the instance asynchronously.
51315139 $ this ->assertEquals ($ expected , course_modules_pending_deletion ($ course ->id , $ gradable ));
51325140 }
51335141}
0 commit comments