@@ -340,7 +340,9 @@ public function test_has_coursecontact_role() {
340340
341341 $ user = $ this ->getDataGenerator ()->create_user ();
342342 $ course = $ this ->getDataGenerator ()->create_course ();
343- role_assign ($ CFG ->coursecontact , $ user ->id , context_course::instance ($ course ->id ));
343+ $ contactroles = preg_split ('/,/ ' , $ CFG ->coursecontact );
344+ $ roleid = reset ($ contactroles );
345+ role_assign ($ roleid , $ user ->id , context_course::instance ($ course ->id ));
344346 $ this ->assertTrue (has_coursecontact_role ($ user ->id ));
345347 }
346348
@@ -800,7 +802,7 @@ public function test_get_archetype_roles() {
800802
801803 create_role ('New student role ' , 'student2 ' , 'New student description ' , 'student ' );
802804 $ roles = get_archetype_roles ('student ' );
803- $ this ->assertCount (2 , $ roles );
805+ $ this ->assertGreaterThanOrEqual (2 , count ( $ roles) );
804806 }
805807
806808 /**
@@ -1508,14 +1510,8 @@ public function test_get_default_enrol_roles() {
15081510 $ allroles = get_all_roles ();
15091511 $ expected = array ($ id2 =>$ allroles [$ id2 ]);
15101512
1511- foreach (get_role_archetypes () as $ archetype ) {
1512- $ defaults = get_default_contextlevels ($ archetype );
1513- if (in_array (CONTEXT_COURSE , $ defaults )) {
1514- $ roles = get_archetype_roles ($ archetype );
1515- foreach ($ roles as $ role ) {
1516- $ expected [$ role ->id ] = $ role ;
1517- }
1518- }
1513+ foreach (get_roles_for_contextlevels (CONTEXT_COURSE ) as $ roleid ) {
1514+ $ expected [$ roleid ] = $ roleid ;
15191515 }
15201516
15211517 $ roles = get_default_enrol_roles ($ coursecontext );
@@ -2694,7 +2690,7 @@ public function test_permission_evaluation() {
26942690 $ testcourses = array ();
26952691 $ testpages = array ();
26962692 $ testblocks = array ();
2697- $ allroles = $ DB ->get_records_menu ('role ' , array (), 'id ' , 'archetype , id ' );
2693+ $ allroles = $ DB ->get_records_menu ('role ' , array (), 'id ' , 'shortname , id ' );
26982694
26992695 $ systemcontext = context_system::instance ();
27002696 $ frontpagecontext = context_course::instance (SITEID );
@@ -3616,8 +3612,8 @@ public function test_update_capabilities() {
36163612 $ this ->resetAfterTest (true );
36173613
36183614 $ froncontext = context_course::instance ($ SITE ->id );
3619- $ student = $ DB ->get_record ('role ' , array ('archetype ' =>'student ' ));
3620- $ teacher = $ DB ->get_record ('role ' , array ('archetype ' =>'teacher ' ));
3615+ $ student = $ DB ->get_record ('role ' , array ('shortname ' =>'student ' ));
3616+ $ teacher = $ DB ->get_record ('role ' , array ('shortname ' =>'teacher ' ));
36213617
36223618 $ existingcaps = $ DB ->get_records ('capabilities ' , array (), 'id ' , 'name, captype, contextlevel, component, riskbitmask ' );
36233619
0 commit comments