mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-41707 allow custom location of external test files used from unit tests
This commit is contained in:
parent
d45e65ccad
commit
a9d2f1b414
8 changed files with 78 additions and 37 deletions
|
@ -452,6 +452,46 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
|
|||
return phpunit_util::get_data_generator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns UTL of the external test file.
|
||||
*
|
||||
* The result depends on the value of following constants:
|
||||
* - TEST_EXTERNAL_FILES_HTTP_URL
|
||||
* - TEST_EXTERNAL_FILES_HTTPS_URL
|
||||
*
|
||||
* They should point to standard external test files repository,
|
||||
* it defaults to 'http://download.moodle.org/unittest'.
|
||||
*
|
||||
* False value means skip tests that require external files.
|
||||
*
|
||||
* @param string $path
|
||||
* @param bool $https true if https required
|
||||
* @return string url
|
||||
*/
|
||||
public function getExternalTestFileUrl($path, $https = false) {
|
||||
$path = ltrim($path, '/');
|
||||
if ($path) {
|
||||
$path = '/'.$path;
|
||||
}
|
||||
if ($https) {
|
||||
if (defined('TEST_EXTERNAL_FILES_HTTPS_URL')) {
|
||||
if (!TEST_EXTERNAL_FILES_HTTPS_URL) {
|
||||
$this->markTestSkipped('Tests using external https test files are disabled');
|
||||
}
|
||||
return TEST_EXTERNAL_FILES_HTTPS_URL.$path;
|
||||
}
|
||||
return 'https://download.moodle.org/unittest'.$path;
|
||||
}
|
||||
|
||||
if (defined('TEST_EXTERNAL_FILES_HTTP_URL')) {
|
||||
if (!TEST_EXTERNAL_FILES_HTTP_URL) {
|
||||
$this->markTestSkipped('Tests using external http test files are disabled');
|
||||
}
|
||||
return TEST_EXTERNAL_FILES_HTTP_URL.$path;
|
||||
}
|
||||
return 'http://download.moodle.org/unittest'.$path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively visit all the files in the source tree. Calls the callback
|
||||
* function with the pathname of each file found.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue