From 20b0afcade2abce24d6fe091d19e3b83dd981bc8 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 3 Sep 2020 11:42:45 +0200 Subject: [PATCH] MOBILE-3523: Use $WWWROOT to get moodle site url in tests --- mod/login/tests/behat/app_basic_usage.feature | 2 +- tests/behat/behat_local_moodlemobileapp.php | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/mod/login/tests/behat/app_basic_usage.feature b/mod/login/tests/behat/app_basic_usage.feature index 0071ad1a7..0aa02605f 100755 --- a/mod/login/tests/behat/app_basic_usage.feature +++ b/mod/login/tests/behat/app_basic_usage.feature @@ -21,7 +21,7 @@ Feature: Test basic usage of login in app Scenario: Add a new site in the app & Site name in displayed when adding a new site When I enter the app And I press the back button in the app - And I set the field "https://campus.example.edu" to "$WEBSERVER" in the app + And I set the field "https://campus.example.edu" to "$WWWROOT" in the app And I press "Connect to your site" in the app Then I should see "Acceptance test site" diff --git a/tests/behat/behat_local_moodlemobileapp.php b/tests/behat/behat_local_moodlemobileapp.php index 603f055bf..1629e0e41 100644 --- a/tests/behat/behat_local_moodlemobileapp.php +++ b/tests/behat/behat_local_moodlemobileapp.php @@ -98,20 +98,16 @@ class behat_local_moodlemobileapp extends behat_base { } /** - * Replaces $WEBSERVER for webserver env variable value, defaults to "webserver" if it is not set. + * Replaces $WWWROOT for the url of the Moodle site. * - * @Transform /^(.*\$WEBSERVER.*)$/ + * @Transform /^(.*\$WWWROOT.*)$/ * @param string $text Text. * @return string */ - public function arg_replace_webserver_env($text) { - $webserver = getenv('WEBSERVER'); + public function arg_replace_wwwroot($text) { + global $CFG; - if ($webserver === false) { - $webserver = 'webserver'; - } - - return str_replace('$WEBSERVER', $webserver, $text); + return str_replace('$WWWROOT', $CFG->behat_wwwroot, $text); } }