diff --git a/local_moodleappbehat/tests/behat/behat_app_helper.php b/local_moodleappbehat/tests/behat/behat_app_helper.php index d67fa4a82..ad25bddb4 100644 --- a/local_moodleappbehat/tests/behat/behat_app_helper.php +++ b/local_moodleappbehat/tests/behat/behat_app_helper.php @@ -292,6 +292,8 @@ class behat_app_helper extends behat_base { /** * Replaces $WWWROOT for the url of the Moodle site. * + * Using $WWWROOTPATTERN will replace it for a regex pattern. + * * @Transform /^(.*\$WWWROOT.*)$/ * @param string $text Text. * @return string @@ -299,7 +301,10 @@ class behat_app_helper extends behat_base { public function replace_wwwroot($text) { global $CFG; - return str_replace('$WWWROOT', $CFG->behat_wwwroot, $text); + $text = str_replace('$WWWROOTPATTERN', preg_quote($CFG->behat_wwwroot, '/'), $text); + $text = str_replace('$WWWROOT', $CFG->behat_wwwroot, $text); + + return $text; } /** diff --git a/src/core/features/login/tests/behat/basic_usage.feature b/src/core/features/login/tests/behat/basic_usage.feature index 6d2691b67..46bc64d17 100755 --- a/src/core/features/login/tests/behat/basic_usage.feature +++ b/src/core/features/login/tests/behat/basic_usage.feature @@ -96,7 +96,7 @@ Feature: Test basic usage of login in app And I should find "You must change your password to proceed." in the app When I press "Change password" "ion-button" in the app - Then the app should have opened a browser tab with url "webserver" + Then the app should have opened a browser tab with url "$WWWROOTPATTERN" When I close the browser tab opened by the app Then I should find "If you didn't change your password correctly, you'll be asked to do it again." in the app @@ -115,7 +115,7 @@ Feature: Test basic usage of login in app But I should not find "Reconnect" in the app When I press "Change password" "ion-button" in the app - Then the app should have opened a browser tab with url "webserver" + Then the app should have opened a browser tab with url "$WWWROOTPATTERN" When I switch to the browser tab opened by the app And I set the field "username" to "student1" diff --git a/src/core/features/user/tests/behat/basic_usage.feature b/src/core/features/user/tests/behat/basic_usage.feature index 5aeadf3c8..21a3f14d2 100755 --- a/src/core/features/user/tests/behat/basic_usage.feature +++ b/src/core/features/user/tests/behat/basic_usage.feature @@ -17,7 +17,7 @@ Feature: Test basic usage of user features And I should find "Before you continue, please fill in the required fields in your user profile." in the app When I press "Complete profile" in the app - Then the app should have opened a browser tab with url "webserver" + Then the app should have opened a browser tab with url "$WWWROOTPATTERN" When I close the browser tab opened by the app Then I should find "If you didn't complete your profile correctly, you'll be asked to do it again." in the app @@ -36,7 +36,7 @@ Feature: Test basic usage of user features But I should not find "Reconnect" in the app When I press "Complete profile" in the app - Then the app should have opened a browser tab with url "webserver" + Then the app should have opened a browser tab with url "$WWWROOTPATTERN" When I switch to the browser tab opened by the app And I set the field "username" to "student1"