MDL-84152 tests: Remove extraneous / in external file URL generation

This commit is contained in:
Andrew Nicols 2025-01-10 14:35:26 +08:00
parent a843eab495
commit 99aac9532a
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
2 changed files with 26 additions and 2 deletions

View File

@ -622,7 +622,7 @@ abstract class advanced_testcase extends base_testcase {
}
return TEST_EXTERNAL_FILES_HTTPS_URL . $path;
}
return "https://download.moodle.org/unittest/{$path}";
return "https://download.moodle.org/unittest{$path}";
}
if (defined('TEST_EXTERNAL_FILES_HTTP_URL')) {
@ -631,7 +631,7 @@ abstract class advanced_testcase extends base_testcase {
}
return TEST_EXTERNAL_FILES_HTTP_URL . $path;
}
return "http://download.moodle.org/unittest/{$path}";
return "http://download.moodle.org/unittest{$path}";
}
/**

View File

@ -292,6 +292,30 @@ final class advanced_test extends \advanced_testcase {
$this->assertInstanceOf('testing_data_generator', $generator);
}
/**
* Some basic tests for the getExternalTestFileUrl() method.
*/
public function test_external_file_url(): void {
$url = self::getExternalTestFileUrl('testfile.txt');
// There should only be a // after the protocol.
$this->assertCount(2, explode('//', $url));
if (defined('TEST_EXTERNAL_FILES_HTTP_URL')) {
$this->assertStringContainsString(TEST_EXTERNAL_FILES_HTTP_URL, $url);
} else {
$this->assertStringContainsString('http://download.moodle.org/unittest', $url);
}
$url = self::getExternalTestFileUrl('testfile.txt', true);
$this->assertCount(2, explode('//', $url));
if (defined('TEST_EXTERNAL_FILES_HTTPS_URL')) {
$this->assertStringContainsString(TEST_EXTERNAL_FILES_HTTPS_URL, $url);
} else {
$this->assertStringContainsString('https://download.moodle.org/unittest', $url);
}
}
public function test_database_mock1(): void {
global $DB;