2323 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
2424 */
2525
26- defined ( ' MOODLE_INTERNAL ' ) || die () ;
26+ namespace tool_trigger ;
2727
28- global $ CFG ;
28+ class course_lookup_step_test extends \advanced_testcase {
29+
30+ /**
31+ * Test user.
32+ * @var
33+ */
34+ protected $ user ;
35+
36+ /**
37+ * Test user.
38+ * @var
39+ */
40+ protected $ course ;
41+
42+ /**
43+ * Event for testing.
44+ * @var \core\event\user_graded
45+ */
46+ private $ event ;
2947
30- class tool_trigger_course_lookup_step_testcase extends advanced_testcase {
3148 /**
3249 * Create a "user_profile_viewed" event, of user1 viewing user2's
3350 * profile. And then run everything else as the cron user.
@@ -41,15 +58,15 @@ public function setup():void {
4158
4259 $ this ->event = \core \event \course_created::create ([
4360 'objectid ' => $ this ->course ->id ,
44- 'context ' => context_course::instance ($ this ->course ->id ),
61+ 'context ' => \ context_course::instance ($ this ->course ->id ),
4562 'other ' => [
4663 'shortname ' => $ this ->course ->shortname ,
4764 'fullname ' => $ this ->course ->fullname
4865 ]
4966 ]);
5067
5168 // Run as the cron user .
52- cron_setup_user ();
69+ \ core \cron:: setup_user ();
5370 }
5471
5572 /**
@@ -65,7 +82,7 @@ public function test_execute_basic() {
6582 );
6683
6784 list ($ status , $ stepresults ) = $ step ->execute (null , null , $ this ->event , []);
68- $ context = context_course::instance ($ this ->course ->id );
85+ $ context = \ context_course::instance ($ this ->course ->id );
6986
7087 $ this ->assertTrue ($ status );
7188 $ this ->assertEquals ($ this ->course ->id , $ stepresults ['course_id ' ]);
@@ -149,14 +166,14 @@ public function test_execute_course_id($courseid, $status, $exception) {
149166 );
150167
151168 if ($ exception ) {
152- $ this ->expectException (' Error ' );
153- $ this ->expectExceptionMessageRegExp ("/Specified courseid field not present in the workflow data:*/ " );
169+ $ this ->expectException (\invalid_parameter_exception::class );
170+ $ this ->expectExceptionMessageMatches ("/Specified courseid field not present in the workflow data:*/ " );
154171 }
155172
156173 list ($ statusresult , $ stepresults ) = $ step ->execute (null , null , $ this ->event , []);
157174
158175 if ($ status ) {
159- $ context = context_course::instance ($ this ->course ->id );
176+ $ context = \ context_course::instance ($ this ->course ->id );
160177 $ this ->assertTrue ($ statusresult );
161178 $ this ->assertEquals ($ this ->course ->id , $ stepresults ['course_id ' ]);
162179 $ this ->assertEquals ($ this ->course ->fullname , $ stepresults ['course_fullname ' ]);
@@ -179,7 +196,7 @@ public function test_execute_course_id_integer() {
179196
180197 list ($ status , $ stepresults ) = $ step ->execute (null , null , $ this ->event , []);
181198
182- $ context = context_course::instance ($ this ->course ->id );
199+ $ context = \ context_course::instance ($ this ->course ->id );
183200 $ this ->assertTrue ($ status );
184201 $ this ->assertEquals ($ this ->course ->id , $ stepresults ['course_id ' ]);
185202 $ this ->assertEquals ($ this ->course ->fullname , $ stepresults ['course_fullname ' ]);
@@ -199,7 +216,7 @@ public function test_execute_course_id_string() {
199216
200217 list ($ status , $ stepresults ) = $ step ->execute (null , null , $ this ->event , []);
201218
202- $ context = context_course::instance ($ this ->course ->id );
219+ $ context = \ context_course::instance ($ this ->course ->id );
203220 $ this ->assertTrue ($ status );
204221 $ this ->assertEquals ($ this ->course ->id , $ stepresults ['course_id ' ]);
205222 $ this ->assertEquals ($ this ->course ->fullname , $ stepresults ['course_fullname ' ]);
0 commit comments