mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
Merge branch 'MDL-48639' of git://github.com/timhunt/moodle
This commit is contained in:
commit
b44a858ff1
@ -98,7 +98,7 @@ class behat_repository_upload extends behat_files {
|
||||
* Uploads a file to filemanager
|
||||
*
|
||||
* @throws ExpectationException Thrown by behat_base::find
|
||||
* @param string $filepath
|
||||
* @param string $filepath Normally a path relative to $CFG->dirroot, but can be an absolute path too.
|
||||
* @param string $filemanagerelement
|
||||
* @param TableNode $data Data to fill in upload form
|
||||
* @param false|string $overwriteaction false if we don't expect that file with the same name already exists,
|
||||
@ -130,13 +130,18 @@ class behat_repository_upload extends behat_files {
|
||||
|
||||
// Attaching specified file to the node.
|
||||
// Replace 'admin/' if it is in start of path with $CFG->admin .
|
||||
$pos = strpos($filepath, 'admin/');
|
||||
if ($pos === 0) {
|
||||
$filepath = $CFG->admin . DIRECTORY_SEPARATOR . substr($filepath, 6);
|
||||
if (substr($filepath, 0, 6) === 'admin/') {
|
||||
$filepath = $CFG->dirroot . DIRECTORY_SEPARATOR . $CFG->admin .
|
||||
DIRECTORY_SEPARATOR . substr($filepath, 6);
|
||||
}
|
||||
$filepath = str_replace('/', DIRECTORY_SEPARATOR, $filepath);
|
||||
$fileabsolutepath = $CFG->dirroot . DIRECTORY_SEPARATOR . $filepath;
|
||||
$file->attachFile($fileabsolutepath);
|
||||
if (!is_readable($filepath)) {
|
||||
$filepath = $CFG->dirroot . DIRECTORY_SEPARATOR . $filepath;
|
||||
if (!is_readable($filepath)) {
|
||||
throw new ExpectationException('The file to be uploaded does not exist.', $this->getSession());
|
||||
}
|
||||
}
|
||||
$file->attachFile($filepath);
|
||||
|
||||
// Fill the form in Upload window.
|
||||
$datahash = $data->getRowsHash();
|
||||
|
Loading…
x
Reference in New Issue
Block a user