diff --git a/enrol/self/lib.php b/enrol/self/lib.php index a125a4c1272..1c931762e7f 100644 --- a/enrol/self/lib.php +++ b/enrol/self/lib.php @@ -403,7 +403,7 @@ class enrol_self_plugin extends enrol_plugin { $a->coursename = format_string($course->fullname, true, array('context'=>$context)); $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id"; - if (trim($instance->customtext1) !== '') { + if (!is_null($instance->customtext1) && trim($instance->customtext1) !== '') { $message = $instance->customtext1; $key = array('{$a->coursename}', '{$a->profileurl}', '{$a->fullname}', '{$a->email}'); $value = array($a->coursename, $a->profileurl, fullname($user), $user->email); diff --git a/enrol/self/tests/behat/self_enrolment.feature b/enrol/self/tests/behat/self_enrolment.feature index bf71cae807f..2599bcca4d9 100644 --- a/enrol/self/tests/behat/self_enrolment.feature +++ b/enrol/self/tests/behat/self_enrolment.feature @@ -140,3 +140,19 @@ Feature: Users can auto-enrol themself in courses where self enrolment is allowe And I navigate to "Unenrol me from C1" in current page administration And I click on "Continue" "button" in the "Confirm" "dialogue" Then I should see "You are unenrolled from the course \"Course 1\"" + + @javascript + Scenario: Self-enrolment enabled with simultaneous guest access + Given I log in as "teacher1" + And I am on the "Course 1" "enrolment methods" page + And I click on "Enable" "link" in the "Self enrolment (Student)" "table_row" + And I click on "Edit" "link" in the "Guest access" "table_row" + And I set the following fields to these values: + | Allow guest access | Yes | + And I press "Save changes" + And I log out + And I log in as "student1" + And I am on "Course 1" course homepage + And I navigate to "Enrol me in this course" in current page administration + And I click on "Enrol me" "button" + Then I should see "Topic 1"