mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-83807 files: Make file_get_all_files_in_draftarea return zip files
This commit is contained in:
parent
e10420df88
commit
408383f20d
@ -855,7 +855,7 @@ function file_get_all_files_in_draftarea(int $draftitemid, string $filepath = '/
|
||||
|
||||
if (!empty($draftfiles)) {
|
||||
foreach ($draftfiles->list as $draftfile) {
|
||||
if ($draftfile->type == 'file') {
|
||||
if ($draftfile->type !== 'folder') {
|
||||
$files[] = $draftfile;
|
||||
}
|
||||
}
|
||||
|
@ -1826,6 +1826,38 @@ EOF;
|
||||
$this->assertEquals($fifthrecord['filename'], $allfiles[4]->filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that zip files in the draftarea are returned.
|
||||
* @covers ::file_get_all_files_in_draftarea
|
||||
*/
|
||||
public function test_file_get_all_files_in_draftarea_zip_files(): void {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
$zip1 = ['filename' => 'basezip.zip'];
|
||||
$file = self::create_draft_file($zip1);
|
||||
|
||||
$zip2 = [
|
||||
'filename' => 'infolder.zip',
|
||||
'filepath' => '/assignment/',
|
||||
'itemid' => $file->get_itemid(),
|
||||
];
|
||||
$file = self::create_draft_file($zip2);
|
||||
|
||||
$otherfile = [
|
||||
'filename' => 'otherfile.txt',
|
||||
'filepath' => '/secondfolder/',
|
||||
'itemid' => $file->get_itemid(),
|
||||
];
|
||||
$file = self::create_draft_file($otherfile);
|
||||
|
||||
$allfiles = file_get_all_files_in_draftarea($file->get_itemid());
|
||||
$this->assertCount(3, $allfiles);
|
||||
$this->assertEquals($zip1['filename'], $allfiles[0]->filename);
|
||||
$this->assertEquals($zip2['filename'], $allfiles[1]->filename);
|
||||
$this->assertEquals($otherfile['filename'], $allfiles[2]->filename);
|
||||
}
|
||||
|
||||
public function test_file_copy_file_to_file_area(): void {
|
||||
// Create two files in different draft areas but owned by the same user.
|
||||
global $USER;
|
||||
|
Loading…
x
Reference in New Issue
Block a user