@@ -116,6 +116,7 @@ public function test_subscription_modes() {
116
116
$ course = $ this ->getDataGenerator ()->create_course ();
117
117
$ options = array ('course ' => $ course ->id );
118
118
$ moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ options );
119
+ $ modulecontext = context_module::instance ($ moodleoverflow ->cmid );
119
120
120
121
// Create a user enrolled in the course as a student.
121
122
list ($ user ) = $ this ->helper_create_users ($ course , 1 );
@@ -129,27 +130,27 @@ public function test_subscription_modes() {
129
130
$ this ->assertEquals (MOODLEOVERFLOW_FORCESUBSCRIBE ,
130
131
\mod_moodleoverflow \subscriptions::get_subscription_mode ($ moodleoverflow ));
131
132
$ 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 ));
133
134
$ this ->assertFalse (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
134
135
135
136
// Test the disallowed subscription.
136
137
\mod_moodleoverflow \subscriptions::set_subscription_mode ($ moodleoverflow ->id , MOODLEOVERFLOW_DISALLOWSUBSCRIBE );
137
138
$ moodleoverflow = $ DB ->get_record ('moodleoverflow ' , array ('id ' => $ moodleoverflow ->id ));
138
139
$ 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 ));
140
141
$ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
141
142
142
143
// Test the initial subscription.
143
144
\mod_moodleoverflow \subscriptions::set_subscription_mode ($ moodleoverflow ->id , MOODLEOVERFLOW_INITIALSUBSCRIBE );
144
145
$ 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 ));
146
147
$ this ->assertFalse (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
147
148
$ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
148
149
149
150
// Test the choose subscription.
150
151
\mod_moodleoverflow \subscriptions::set_subscription_mode ($ moodleoverflow ->id , MOODLEOVERFLOW_CHOOSESUBSCRIBE );
151
152
$ 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 ));
153
154
$ this ->assertFalse (\mod_moodleoverflow \subscriptions::subscription_disabled ($ moodleoverflow ));
154
155
$ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_forcesubscribed ($ moodleoverflow ));
155
156
}
@@ -1376,7 +1377,8 @@ public function test_is_subscribable_logged_out($options) {
1376
1377
$ options ['course ' ] = $ course ->id ;
1377
1378
$ moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ options );
1378
1379
1379
- $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
1380
+ $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ,
1381
+ context_module::instance ($ moodleoverflow ->cmid )));
1380
1382
}
1381
1383
1382
1384
/**
@@ -1399,7 +1401,8 @@ public function test_is_subscribable_is_guest($options) {
1399
1401
$ options ['course ' ] = $ course ->id ;
1400
1402
$ moodleoverflow = $ this ->getDataGenerator ()->create_module ('moodleoverflow ' , $ options );
1401
1403
1402
- $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ));
1404
+ $ this ->assertFalse (\mod_moodleoverflow \subscriptions::is_subscribable ($ moodleoverflow ,
1405
+ context_module::instance ($ moodleoverflow ->cmid )));
1403
1406
}
1404
1407
1405
1408
/**
@@ -1449,6 +1452,7 @@ public function test_is_subscribable_loggedin($options, $expect) {
1449
1452
$ this ->getDataGenerator ()->enrol_user ($ user ->id , $ course ->id );
1450
1453
$ this ->setUser ($ user );
1451
1454
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 )));
1453
1457
}
1454
1458
}
0 commit comments