@@ -116,6 +116,7 @@ public function test_subscription_modes() {
116116 $ course = $ this ->getDataGenerator ()->create_course ();
117117 $ options = array ('course ' => $ course ->id );
118118 $ moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ options );
119+ $ modulecontext = context_module::instance ($ moodleoverflow ->cmid );
119120
120121 // Create a user enrolled in the course as a student.
121122 list ($ user ) = $ this ->helper_create_users ($ course , 1 );
@@ -129,27 +130,27 @@ public function test_subscription_modes() {
129130 $ this ->assertEquals (MOODLEOVERFLOW_FORCESUBSCRIBE ,
130131 \mod_moodleoverflow \subscriptions::get_subscription_mode ($ moodleoverflow ));
131132 $ this ->assertTrue (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
132- $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
133+ $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow, $ modulecontext ));
133134 $ this ->assertFalse (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
134135
135136 // Test the disallowed subscription.
136137 \mod_moodleoverflow \subscriptions::set_subscription_mode ($ moodleoverflow ->id , MOODLEOVERFLOW_DISALLOWSUBSCRIBE );
137138 $ moodleoverflow = $ DB ->get_record ('moodleoverflow ' , array ('id ' => $ moodleoverflow ->id ));
138139 $ this ->assertTrue (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
139- $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
140+ $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow, $ modulecontext ));
140141 $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
141142
142143 // Test the initial subscription.
143144 \mod_moodleoverflow \subscriptions::set_subscription_mode ($ moodleoverflow ->id , MOODLEOVERFLOW_INITIALSUBSCRIBE );
144145 $ moodleoverflow = $ DB ->get_record ('moodleoverflow ' , array ('id ' => $ moodleoverflow ->id ));
145- $ this ->assertTrue (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
146+ $ this ->assertTrue (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow, $ modulecontext ));
146147 $ this ->assertFalse (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
147148 $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
148149
149150 // Test the choose subscription.
150151 \mod_moodleoverflow \subscriptions::set_subscription_mode ($ moodleoverflow ->id , MOODLEOVERFLOW_CHOOSESUBSCRIBE );
151152 $ moodleoverflow = $ DB ->get_record ('moodleoverflow ' , array ('id ' => $ moodleoverflow ->id ));
152- $ this ->assertTrue (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
153+ $ this ->assertTrue (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow, $ modulecontext ));
153154 $ this ->assertFalse (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
154155 $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
155156 }
@@ -1376,7 +1377,8 @@ public function test_is_subscribable_logged_out($options) {
13761377 $ options ['course ' ] = $ course ->id ;
13771378 $ moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ options );
13781379
1379- $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
1380+ $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ,
1381+ context_module::instance ($ moodleoverflow ->cmid )));
13801382 }
13811383
13821384 /**
@@ -1399,7 +1401,8 @@ public function test_is_subscribable_is_guest($options) {
13991401 $ options ['course ' ] = $ course ->id ;
14001402 $ moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ options );
14011403
1402- $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
1404+ $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ,
1405+ context_module::instance ($ moodleoverflow ->cmid )));
14031406 }
14041407
14051408 /**
@@ -1449,6 +1452,7 @@ public function test_is_subscribable_loggedin($options, $expect) {
14491452 $ this ->getDataGenerator ()->enrol_user ($ user ->id , $ course ->id );
14501453 $ this ->setUser ($ user );
14511454
1452- $ this ->assertEquals ($ expect , \mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
1455+ $ this ->assertEquals ($ expect , \mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ,
1456+ context_module::instance ($ moodleoverflow ->cmid )));
14531457 }
14541458}
0 commit comments