diff --git a/admin/tool/httpsreplace/tests/httpsreplace_test.php b/admin/tool/httpsreplace/tests/httpsreplace_test.php
index c10ea2f658d..e3599c63cb9 100644
--- a/admin/tool/httpsreplace/tests/httpsreplace_test.php
+++ b/admin/tool/httpsreplace/tests/httpsreplace_test.php
@@ -47,12 +47,12 @@ class httpsreplace_test extends \advanced_testcase {
"Test image from another site should be replaced" => [
"content" => '
',
"outputregex" => '/UPDATE/',
- "expectedcontent" => '
',
+ "expectedcontent" => '
',
],
"Test object from another site should be replaced" => [
"content" => '
'
',
],
"Broken URL should not be changed" => [
@@ -113,11 +113,25 @@ class httpsreplace_test extends \advanced_testcase {
$this->getExternalTestFileUrl('/test.jpg', false) . '">',
"outputregex" => '/UPDATE/',
"expectedcontent" => '
',
+ $this->get_converted_http_link('/test.jpg') . '">',
],
];
}
+ /**
+ * Convert the HTTP external test file URL to use HTTPS.
+ *
+ * Note: We *must not* use getExternalTestFileUrl with the True option
+ * here, becase it is reasonable to have only one of these set due to
+ * issues with SSL certificates.
+ *
+ * @param string $path Path to be rewritten
+ * @return string
+ */
+ protected function get_converted_http_link($path) {
+ return preg_replace('/^http:/', 'https:', $this->getExternalTestFileUrl($path, false));
+ }
+
/**
* Test upgrade_http_links
* @param string $content Example content that we'll attempt to replace.
@@ -152,7 +166,7 @@ class httpsreplace_test extends \advanced_testcase {
// Get the http url, since the default test wwwroot is https.
$wwwrootdomain = 'www.example.com';
$wwwroothttp = preg_replace('/^https:/', 'http:', $CFG->wwwroot);
- $testdomain = 'download.moodle.org';
+ $testdomain = $this->get_converted_http_link('');
return [
"Test image from an available site so shouldn't be reported" => [
"content" => '
',