diff --git a/admin/tool/httpsreplace/tests/httpsreplace_test.php b/admin/tool/httpsreplace/tests/httpsreplace_test.php index 629c5520a7c..b4de24d07a9 100644 --- a/admin/tool/httpsreplace/tests/httpsreplace_test.php +++ b/admin/tool/httpsreplace/tests/httpsreplace_test.php @@ -29,73 +29,232 @@ defined('MOODLE_INTERNAL') || die(); class httpsreplace_test extends \advanced_testcase { - public function test_find_and_replace() { + /** + * Data provider for test_upgrade_http_links + */ + public function upgrade_http_links_provider() { + global $CFG; + // Get the http url, since the default test wwwroot is https. + $wwwroothttp = preg_replace('/^https:/', 'http:', $CFG->wwwroot); + return [ + "Test image from another site should be replaced" => [ + "content" => '', + "outputregex" => '/UPDATE/', + "expectedcontent" => '', + ], + "Test object from another site should be replaced" => [ + "content" => '', + "outputregex" => '/UPDATE/', + "expectedcontent" => '', + ], + "Link that is from this site should be replaced" => [ + "content" => '', + "outputregex" => '/UPDATE/', + "expectedcontent" => '', + ], + "Link that is from this site, https new so doesn't need replacing" => [ + "content" => '', + "outputregex" => '/^$/', + "expectedcontent" => '', + ], + "Unavailable image should be replaced" => [ + "content" => '', + "outputregex" => '/UPDATE/', + "expectedcontent" => '', + ], + "Https content that has an http url as a param should not be replaced" => [ + "content" => '', + "outputregex" => '/^$/', + "expectedcontent" => '', + ], + "Known supported domain should be replaced" => [ + "content" => '