MDL-65130 files: Add @covers Annotation

This commit is contained in:
Andrew Nicols 2019-03-21 09:00:41 +08:00
parent abbabc5a91
commit 51114517be
3 changed files with 494 additions and 0 deletions

View File

@ -30,10 +30,20 @@ require_once($CFG->libdir . '/filelib.php');
require_once($CFG->dirroot . '/repository/lib.php');
require_once($CFG->libdir . '/filestorage/stored_file.php');
/**
* Unit tests for /lib/filestorage/file_storage.php
*
* @copyright 2012 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass file_storage
*/
class core_files_file_storage_testcase extends advanced_testcase {
/**
* Files can be created from strings.
*
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string() {
global $DB;
@ -107,6 +117,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Local files can be added to the filepool
*
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname() {
global $CFG, $DB;
@ -189,6 +202,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Tests get get file.
*
* @covers ::get_file
* @covers ::<!public>
*/
public function test_get_file() {
global $CFG;
@ -226,7 +242,10 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Local images can be added to the filepool and their preview can be obtained
*
* @param stored_file $file
* @depends test_get_file
* @covers ::get_file_preview
* @covers ::<!public>
*/
public function test_get_file_preview(stored_file $file) {
global $CFG;
@ -246,6 +265,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->get_file_preview($file, 'amodewhichdoesntexist');
}
/**
* Tests for get_file_preview without an image.
*
* @covers ::get_file_preview
* @covers ::<!public>
*/
public function test_get_file_preview_nonimage() {
$this->resetAfterTest(true);
$syscontext = context_system::instance();
@ -271,6 +296,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
* Make sure renaming is working
*
* @copyright 2012 Dongsheng Cai {@link http://dongsheng.org}
* @covers stored_file::rename
* @covers ::<!public>
*/
public function test_file_renaming() {
global $CFG;
@ -316,6 +343,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
* Create file from reference tests
*
* @copyright 2012 Dongsheng Cai {@link http://dongsheng.org}
* @covers ::create_file_from_reference
* @covers ::<!public>
*/
public function test_create_file_from_reference() {
global $CFG, $DB;
@ -401,6 +430,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
* Create file from reference tests
*
* @copyright 2012 Dongsheng Cai {@link http://dongsheng.org}
* @covers ::create_file_from_reference
* @covers ::<!public>
*/
public function test_create_file_from_reference_with_content_hash() {
global $CFG, $DB;
@ -506,6 +537,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
return $user;
}
/**
* Tests for get_area_files
*
* @covers ::get_area_files
* @covers ::<!public>
*/
public function test_get_area_files() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -561,6 +598,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEmpty($areafiles);
}
/**
* Tests for get_area_tree
*
* @covers ::get_area_tree
* @covers ::<!public>
*/
public function test_get_area_tree() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -615,6 +658,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals($filerecord['filename'], $subdirfile->get_filename());
}
/**
* Tests for get_file_by_id
*
* @covers ::get_file_by_id
* @covers ::<!public>
*/
public function test_get_file_by_id() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -631,6 +680,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertFalse($doesntexist);
}
/**
* Tests for get_file_by_hash
*
* @covers ::get_file_by_hash
* @covers ::<!public>
*/
public function test_get_file_by_hash() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -646,6 +701,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertFalse($doesntexist);
}
/**
* Tests for get_external_files
*
* @covers ::get_external_files
* @covers ::<!public>
*/
public function test_get_external_files() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -707,6 +768,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals($aliasfile3->get_referencefileid(), $aliasfile2->get_referencefileid());
}
/**
* Tests for create_directory with a negative contextid.
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_contextid_negative() {
$fs = get_file_storage();
@ -714,6 +781,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory(-1, 'core', 'unittest', 0, '/');
}
/**
* Tests for create_directory with an invalid contextid.
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_contextid_invalid() {
$fs = get_file_storage();
@ -721,6 +794,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory('not an int', 'core', 'unittest', 0, '/');
}
/**
* Tests for create_directory with an invalid component.
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_component_invalid() {
$fs = get_file_storage();
$syscontext = context_system::instance();
@ -729,6 +808,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory($syscontext->id, 'bad/component', 'unittest', 0, '/');
}
/**
* Tests for create_directory with an invalid filearea.
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_filearea_invalid() {
$fs = get_file_storage();
$syscontext = context_system::instance();
@ -737,6 +822,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory($syscontext->id, 'core', 'bad-filearea', 0, '/');
}
/**
* Tests for create_directory with a negative itemid
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_itemid_negative() {
$fs = get_file_storage();
$syscontext = context_system::instance();
@ -745,6 +836,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory($syscontext->id, 'core', 'unittest', -1, '/');
}
/**
* Tests for create_directory with an invalid itemid
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_itemid_invalid() {
$fs = get_file_storage();
$syscontext = context_system::instance();
@ -753,6 +850,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory($syscontext->id, 'core', 'unittest', 'notanint', '/');
}
/**
* Tests for create_directory with an invalid filepath
*
* @covers ::create_directory
* @covers ::<!public>
*/
public function test_create_directory_filepath_invalid() {
$fs = get_file_storage();
$syscontext = context_system::instance();
@ -761,6 +864,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_directory($syscontext->id, 'core', 'unittest', 0, '/not-with-trailing/or-leading-slash');
}
/**
* Tests for get_directory_files.
*
* @covers ::get_directory_files
* @covers ::<!public>
*/
public function test_get_directory_files() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -818,6 +927,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
}
}
/**
* Tests for search_references.
*
* @covers ::search_references
* @covers ::<!public>
*/
public function test_search_references() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -890,6 +1005,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertTrue($exceptionthrown);
}
/**
* Tests for delete_area_files.
*
* @covers ::delete_area_files
* @covers ::<!public>
*/
public function test_delete_area_files() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -905,6 +1026,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals(0, count($areafiles));
}
/**
* Tests for delete_area_files using an itemid.
*
* @covers ::delete_area_files
* @covers ::<!public>
*/
public function test_delete_area_files_itemid() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -919,6 +1046,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals(4, count($areafiles));
}
/**
* Tests for delete_area_files_select.
*
* @covers ::delete_area_files_select
* @covers ::<!public>
*/
public function test_delete_area_files_select() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -934,6 +1067,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals(0, count($areafiles));
}
/**
* Tests for delete_component_files.
*
* @covers ::delete_component_files
* @covers ::<!public>
*/
public function test_delete_component_files() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -945,6 +1084,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals(0, count($areafiles));
}
/**
* Tests for create_file_from_url.
*
* @covers ::create_file_from_url
* @covers ::<!public>
*/
public function test_create_file_from_url() {
$this->resetAfterTest(true);
@ -975,6 +1120,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$file3 = $this->assertInstanceOf('stored_file', $file3);
}
/**
* Tests for cron.
*
* @covers ::cron
* @covers ::<!public>
*/
public function test_cron() {
$this->resetAfterTest(true);
@ -986,6 +1137,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->cron();
}
/**
* Tests for is_area_empty.
*
* @covers ::is_area_empty
* @covers ::<!public>
*/
public function test_is_area_empty() {
$user = $this->setup_three_private_files();
$fs = get_file_storage();
@ -998,6 +1155,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertTrue($fs->is_area_empty($user->ctxid, 'user', 'private', 9999, false));
}
/**
* Tests for move_area_files_to_new_context.
*
* @covers ::move_area_files_to_new_context
* @covers ::<!public>
*/
public function test_move_area_files_to_new_context() {
$this->resetAfterTest(true);
@ -1047,6 +1210,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertEquals($movedfile->get_contenthash(), $originalfile->get_contenthash());
}
/**
* Tests for convert_image.
*
* @covers ::convert_image
* @covers ::<!public>
*/
public function test_convert_image() {
global $CFG;
@ -1075,6 +1244,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertInstanceOf('stored_file', $converted);
}
/**
* Tests for convert_image with a PNG.
*
* @covers ::convert_image
* @covers ::<!public>
*/
public function test_convert_image_png() {
global $CFG;
@ -1153,6 +1328,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_file_invalid() {
$this->resetAfterTest(true);
@ -1168,6 +1345,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid contextid
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_contextid_invalid() {
$this->resetAfterTest(true);
@ -1187,6 +1366,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid component
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_component_invalid() {
$this->resetAfterTest(true);
@ -1206,6 +1387,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid filearea
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_filearea_invalid() {
$this->resetAfterTest(true);
@ -1225,6 +1408,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid itemid
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_itemid_invalid() {
$this->resetAfterTest(true);
@ -1244,6 +1429,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file path
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_filepath_invalid() {
$this->resetAfterTest(true);
@ -1263,6 +1450,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file name
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_filename_invalid() {
$this->resetAfterTest(true);
@ -1281,6 +1470,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file timecreated
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_timecreated_invalid() {
$this->resetAfterTest(true);
@ -1300,6 +1491,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file timemodified
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_timemodified_invalid() {
$this->resetAfterTest(true);
@ -1319,6 +1512,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException stored_file_creation_exception
* @expectedExceptionMessage Can not create file "1/core/phpunit/0/testfile.txt"
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile_duplicate() {
$this->resetAfterTest(true);
@ -1333,6 +1528,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$fs->create_file_from_storedfile($filerecord, $file1->get_id());
}
/**
* Tests for create_file_from_storedfile.
*
* @covers ::create_file_from_storedfile
* @covers ::<!public>
*/
public function test_create_file_from_storedfile() {
$this->resetAfterTest(true);
@ -1370,6 +1571,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid contextid
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_contextid_invalid() {
$this->resetAfterTest(true);
@ -1385,6 +1588,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid component
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_component_invalid() {
$this->resetAfterTest(true);
@ -1400,6 +1605,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid filearea
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_filearea_invalid() {
$this->resetAfterTest(true);
@ -1415,6 +1622,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid itemid
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_itemid_invalid() {
$this->resetAfterTest(true);
@ -1430,6 +1639,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file path
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_filepath_invalid() {
$this->resetAfterTest(true);
@ -1445,6 +1656,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file name
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_filename_invalid() {
$this->resetAfterTest(true);
@ -1460,6 +1673,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file timecreated
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_timecreated_invalid() {
$this->resetAfterTest(true);
@ -1477,6 +1692,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file timemodified
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_timemodified_invalid() {
$this->resetAfterTest(true);
@ -1489,6 +1706,11 @@ class core_files_file_storage_testcase extends advanced_testcase {
$file1 = $fs->create_file_from_string($filerecord, 'text contents');
}
/**
* Tests for create_file_from_string with a duplicate string.
* @covers ::create_file_from_string
* @covers ::<!public>
*/
public function test_create_file_from_string_duplicate() {
$this->resetAfterTest(true);
@ -1505,6 +1727,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid contextid
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_contextid_invalid() {
global $CFG;
@ -1523,6 +1747,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid component
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_component_invalid() {
global $CFG;
@ -1541,6 +1767,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid filearea
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_filearea_invalid() {
global $CFG;
@ -1559,6 +1787,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid itemid
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_itemid_invalid() {
global $CFG;
@ -1577,6 +1807,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file path
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_filepath_invalid() {
global $CFG;
@ -1595,6 +1827,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file name
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_filename_invalid() {
global $CFG;
@ -1613,6 +1847,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file timecreated
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_timecreated_invalid() {
global $CFG;
@ -1631,6 +1867,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException file_exception
* @expectedExceptionMessage Invalid file timemodified
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_timemodified_invalid() {
global $CFG;
@ -1649,6 +1887,8 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* @expectedException stored_file_creation_exception
* @expectedExceptionMessage Can not create file "1/core/phpunit/0/testfile.txt"
* @covers ::create_file_from_pathname
* @covers ::<!public>
*/
public function test_create_file_from_pathname_duplicate_file() {
global $CFG;
@ -1668,6 +1908,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Calling stored_file::delete_reference() on a non-reference file throws coding_exception
*
* @covers stored_file::delete_reference
* @covers ::<!public>
*/
public function test_delete_reference_on_nonreference() {
@ -1694,6 +1937,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Calling stored_file::delete_reference() on a reference file does not affect other
* symlinks to the same original
*
* @covers stored_file::delete_reference
* @covers ::<!public>
*/
public function test_delete_reference_one_symlink_does_not_rule_them_all() {
@ -1859,6 +2105,12 @@ class core_files_file_storage_testcase extends advanced_testcase {
$this->assertNull($symlink2->get_referencefileid());
}
/**
* Tests for get_unused_filename.
*
* @covers ::get_unused_filename
* @covers ::<!public>
*/
public function test_get_unused_filename() {
global $USER;
$this->resetAfterTest(true);
@ -1924,6 +2176,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Test that mimetype_from_file returns appropriate output when the
* file could not be found.
*
* @covers ::mimetype
* @covers ::<!public>
*/
public function test_mimetype_not_found() {
$mimetype = file_storage::mimetype('/path/to/nonexistent/file');
@ -1937,6 +2192,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
* Note: this is not intended to check that functions outside of this
* file works. It is intended to validate the codepath contains no
* errors and behaves as expected.
*
* @covers ::mimetype
* @covers ::<!public>
*/
public function test_mimetype_known() {
$filepath = __DIR__ . '/fixtures/testimage.jpg';
@ -1947,6 +2205,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
/**
* Test that mimetype_from_file returns appropriate output when the
* file could not be found.
*
* @covers ::mimetype
* @covers ::<!public>
*/
public function test_mimetype_from_file_not_found() {
$mimetype = file_storage::mimetype_from_file('/path/to/nonexistent/file');
@ -1960,6 +2221,9 @@ class core_files_file_storage_testcase extends advanced_testcase {
* Note: this is not intended to check that functions outside of this
* file works. It is intended to validate the codepath contains no
* errors and behaves as expected.
*
* @covers ::mimetype
* @covers ::<!public>
*/
public function test_mimetype_from_file_known() {
$filepath = __DIR__ . '/fixtures/testimage.jpg';

View File

@ -36,6 +36,7 @@ require_once($CFG->libdir . '/filestorage/file_system_filedir.php');
* @category files
* @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass file_system_filedir
*/
class core_files_file_system_filedir_testcase extends advanced_testcase {
@ -137,6 +138,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that an appropriate error is shown when the filedir directory
* is not writable.
*
* @covers ::__construct
* @covers ::<!public>
*/
public function test_readonly_filesystem_filedir() {
$this->resetAfterTest();
@ -159,6 +163,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that an appropriate error is shown when the trash directory
* is not writable.
*
* @covers ::__construct
* @covers ::<!public>
*/
public function test_readonly_filesystem_trashdir() {
$this->resetAfterTest();
@ -180,6 +187,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that the standard Moodle warning message is put into the filedir.
*
* @covers ::__construct
* @covers ::<!public>
*/
public function test_warnings_put_in_place() {
$this->resetAfterTest();
@ -198,6 +208,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that the default implementation of get_remote_path_from_hash
* simply calls get_local_path_from_hash.
*
* @covers ::get_remote_path_from_hash
* @covers ::<!public>
*/
public function test_get_remote_path_from_hash() {
$filecontent = 'example content';
@ -223,6 +236,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test the stock implementation of get_local_path_from_storedfile_with_recovery with no file found and
* a failed recovery.
*
* @covers ::get_local_path_from_storedfile
* @covers ::<!public>
*/
public function test_get_local_path_from_storedfile_with_recovery() {
$filecontent = 'example content';
@ -251,6 +267,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test the stock implementation of get_local_path_from_storedfile_with_recovery with no file found and
* a failed recovery.
*
* @covers ::get_local_path_from_storedfile
* @covers ::<!public>
*/
public function test_get_local_path_from_storedfile_without_recovery() {
$filecontent = 'example content';
@ -282,6 +301,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
* @dataProvider contenthash_dataprovider
* @param string $hash contenthash to test
* @param string $hashdir Expected format of content directory
*
* @covers ::get_fulldir_from_hash
* @covers ::<!public>
*/
public function test_get_fulldir_from_hash($hash, $hashdir) {
global $CFG;
@ -302,6 +324,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
* @dataProvider contenthash_dataprovider
* @param string $hash contenthash to test
* @param string $hashdir Expected format of content directory
*
* @covers ::get_fulldir_from_storedfile
* @covers ::<!public>
*/
public function test_get_fulldir_from_storedfile($hash, $hashdir) {
global $CFG;
@ -332,6 +357,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
* @dataProvider contenthash_dataprovider
* @param string $hash contenthash to test
* @param string $hashdir Expected format of content directory
*
* @covers ::get_contentdir_from_hash
* @covers ::<!public>
*/
public function test_get_contentdir_from_hash($hash, $hashdir) {
$method = new ReflectionMethod(file_system_filedir::class, 'get_contentdir_from_hash');
@ -350,6 +378,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
* @dataProvider contenthash_dataprovider
* @param string $hash contenthash to test
* @param string $hashdir Expected format of content directory
*
* @covers ::get_contentpath_from_hash
* @covers ::<!public>
*/
public function test_get_contentpath_from_hash($hash, $hashdir) {
$method = new ReflectionMethod(file_system_filedir::class, 'get_contentpath_from_hash');
@ -369,6 +400,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
* @dataProvider contenthash_dataprovider
* @param string $hash contenthash to test
* @param string $hashdir Expected format of content directory
*
* @covers ::get_trash_fullpath_from_hash
* @covers ::<!public>
*/
public function test_get_trash_fullpath_from_hash($hash, $hashdir) {
global $CFG;
@ -389,6 +423,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
* @dataProvider contenthash_dataprovider
* @param string $hash contenthash to test
* @param string $hashdir Expected format of content directory
*
* @covers ::get_trash_fulldir_from_hash
* @covers ::<!public>
*/
public function test_get_trash_fulldir_from_hash($hash, $hashdir) {
global $CFG;
@ -404,6 +441,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that copying a file to a target from a stored_file works as anticipated.
*
* @covers ::copy_content_from_storedfile
* @covers ::<!public>
*/
public function test_copy_content_from_storedfile() {
$this->resetAfterTest();
@ -440,6 +480,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that content recovery works.
*
* @covers ::recover_file
* @covers ::<!public>
*/
public function test_recover_file() {
$this->resetAfterTest();
@ -478,6 +521,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that content recovery works.
*
* @covers ::recover_file
* @covers ::<!public>
*/
public function test_recover_file_already_present() {
$this->resetAfterTest();
@ -515,6 +561,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that content recovery works.
*
* @covers ::recover_file
* @covers ::<!public>
*/
public function test_recover_file_size_mismatch() {
$this->resetAfterTest();
@ -550,6 +599,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that content recovery works.
*
* @covers ::recover_file
* @covers ::<!public>
*/
public function test_recover_file_has_mismatch() {
$this->resetAfterTest();
@ -586,6 +638,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that content recovery works when the content file is in the
* alt trash directory.
*
* @covers ::recover_file
* @covers ::<!public>
*/
public function test_recover_file_alttrash() {
$this->resetAfterTest();
@ -619,6 +674,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that an appropriate error message is generated when adding a
* file to the pool when the pool directory structure is not writable.
*
* @covers ::recover_file
* @covers ::<!public>
*/
public function test_recover_file_contentdir_readonly() {
$this->resetAfterTest();
@ -654,6 +712,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test adding a file to the pool.
*
* @covers ::add_file_from_path
* @covers ::<!public>
*/
public function test_add_file_from_path() {
$this->resetAfterTest();
@ -688,6 +749,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that an appropriate error message is generated when adding an
* unavailable file to the pool is attempted.
*
* @covers ::add_file_from_path
* @covers ::<!public>
*/
public function test_add_file_from_path_file_unavailable() {
$this->resetAfterTest();
@ -706,6 +770,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that an appropriate error message is generated when specifying
* the wrong contenthash when adding a file to the pool.
*
* @covers ::add_file_from_path
* @covers ::<!public>
*/
public function test_add_file_from_path_mismatched_hash() {
$this->resetAfterTest();
@ -726,6 +793,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that an appropriate error message is generated when an existing
* file in the pool has the wrong contenthash
*
* @covers ::add_file_from_path
* @covers ::<!public>
*/
public function test_add_file_from_path_existing_content_invalid() {
$this->resetAfterTest();
@ -769,6 +839,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that an appropriate error message is generated when adding a
* file to the pool when the pool directory structure is not writable.
*
* @covers ::add_file_from_path
* @covers ::<!public>
*/
public function test_add_file_from_path_existing_cannot_write_hashpath() {
$this->resetAfterTest();
@ -800,6 +873,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test adding a string to the pool.
*
* @covers ::add_file_from_string
* @covers ::<!public>
*/
public function test_add_file_from_string() {
$this->resetAfterTest();
@ -825,6 +901,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test that an appropriate error message is generated when adding a
* string to the pool when the pool directory structure is not writable.
*
* @covers ::add_file_from_string
* @covers ::<!public>
*/
public function test_add_file_from_string_existing_cannot_write_hashpath() {
$this->resetAfterTest();
@ -854,6 +933,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test adding a string to the pool when an item with the same
* contenthash is already present.
*
* @covers ::add_file_from_string
* @covers ::<!public>
*/
public function test_add_file_from_string_existing_matches() {
$this->resetAfterTest();
@ -886,6 +968,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test the cleanup of deleted files when there are no files to delete.
*
* @covers ::remove_file
* @covers ::<!public>
*/
public function test_remove_file_missing() {
$this->resetAfterTest();
@ -907,6 +992,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test the cleanup of deleted files when a file already exists in the
* trash for that path.
*
* @covers ::remove_file
* @covers ::<!public>
*/
public function test_remove_file_existing_trash() {
$this->resetAfterTest();
@ -934,6 +1022,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that remove_file does nothing with an empty file.
*
* @covers ::remove_file
* @covers ::<!public>
*/
public function test_remove_file_empty() {
$this->resetAfterTest();
@ -955,6 +1046,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that remove_file does nothing when a file is still
* in use.
*
* @covers ::remove_file
* @covers ::<!public>
*/
public function test_remove_file_in_use() {
$this->resetAfterTest();
@ -986,6 +1080,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Ensure that remove_file removes the file when it is no
* longer in use.
*
* @covers ::remove_file
* @covers ::<!public>
*/
public function test_remove_file_expired() {
$this->resetAfterTest();
@ -1016,6 +1113,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
/**
* Test purging the cache.
*
* @covers ::empty_trash
* @covers ::<!public>
*/
public function test_empty_trash() {
$this->resetAfterTest();

View File

@ -35,6 +35,7 @@ require_once($CFG->libdir . '/filestorage/file_system.php');
* @category phpunit
* @copyright 2017 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass file_system
*/
class core_files_file_system_testcase extends advanced_testcase {
@ -107,6 +108,8 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the file system is not clonable.
*
* @covers ::<!public>
*/
public function test_not_cloneable() {
$reflection = new ReflectionClass('file_system');
@ -115,6 +118,8 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the filedir file_system extension is used by default.
*
* @covers ::<!public>
*/
public function test_default_class() {
$this->resetAfterTest();
@ -131,6 +136,8 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the specified file_system extension class is used.
*
* @covers ::<!public>
*/
public function test_supplied_class() {
global $CFG;
@ -151,6 +158,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that the readfile function outputs content to disk.
*
* @covers ::readfile
* @covers ::<!public>
*/
public function test_readfile_remote() {
global $CFG;
@ -182,6 +192,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that the readfile function outputs content to disk.
*
* @covers ::readfile
* @covers ::<!public>
*/
public function test_readfile_local() {
global $CFG;
@ -218,6 +231,9 @@ class core_files_file_system_testcase extends advanced_testcase {
* @dataProvider get_local_path_from_storedfile_provider
* @param array $args The additional args to pass to get_local_path_from_storedfile
* @param bool $fetch Whether the combination of args should have caused a fetch
*
* @covers ::get_local_path_from_storedfile
* @covers ::<!public>
*/
public function test_get_local_path_from_storedfile($args, $fetch) {
$filepath = '/path/to/file';
@ -245,6 +261,9 @@ class core_files_file_system_testcase extends advanced_testcase {
* Ensure that the default implementation of get_remote_path_from_storedfile
* simply calls get_local_path_from_storedfile without requiring a
* fetch.
*
* @covers ::get_remote_path_from_storedfile
* @covers ::<!public>
*/
public function test_get_remote_path_from_storedfile() {
$filepath = '/path/to/file';
@ -275,6 +294,9 @@ class core_files_file_system_testcase extends advanced_testcase {
* of the file.
*
* Fetching the file is optional.
*
* @covers ::is_file_readable_locally_by_hash
* @covers ::<!public>
*/
public function test_is_file_readable_locally_by_hash() {
$filecontent = 'example content';
@ -294,6 +316,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_locally_by_hash with an empty file.
*
* @covers ::is_file_readable_locally_by_hash
* @covers ::<!public>
*/
public function test_is_file_readable_locally_by_hash_empty() {
$filecontent = '';
@ -311,6 +336,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.
*
* @covers ::is_file_readable_remotely_by_hash
* @covers ::<!public>
*/
public function test_is_file_readable_remotely_by_hash() {
$filecontent = 'example content';
@ -329,6 +357,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.
*
* @covers ::is_file_readable_remotely_by_hash
* @covers ::<!public>
*/
public function test_is_file_readable_remotely_by_hash_empty() {
$filecontent = '';
@ -346,6 +377,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.
*
* @covers ::is_file_readable_remotely_by_hash
* @covers ::<!public>
*/
public function test_is_file_readable_remotely_by_hash_not_found() {
$filecontent = 'example content';
@ -364,6 +398,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.
*
* @covers ::is_file_readable_remotely_by_storedfile
* @covers ::<!public>
*/
public function test_is_file_readable_remotely_by_storedfile() {
$file = $this->get_stored_file('example content');
@ -380,6 +417,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.
*
* @covers ::is_file_readable_remotely_by_storedfile
* @covers ::<!public>
*/
public function test_is_file_readable_remotely_by_storedfile_empty() {
$fs = $this->get_testable_mock([
@ -395,6 +435,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_locally_by_storedfile with an empty file.
*
* @covers ::is_file_readable_locally_by_storedfile
* @covers ::<!public>
*/
public function test_is_file_readable_locally_by_storedfile_empty() {
$fs = $this->get_testable_mock([
@ -410,6 +453,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.
*
* @covers ::is_file_readable_locally_by_storedfile
* @covers ::<!public>
*/
public function test_is_file_readable_remotely_by_storedfile_not_found() {
$file = $this->get_stored_file('example content');
@ -426,6 +472,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_locally_by_storedfile with a valid file.
*
* @covers ::is_file_readable_locally_by_storedfile
* @covers ::<!public>
*/
public function test_is_file_readable_locally_by_storedfile_unreadable() {
$fs = $this->get_testable_mock([
@ -442,6 +491,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of is_file_readable_locally_by_storedfile with a valid file should pass fetch.
*
* @covers ::is_file_readable_locally_by_storedfile
* @covers ::<!public>
*/
public function test_is_file_readable_locally_by_storedfile_passes_fetch() {
$fs = $this->get_testable_mock([
@ -458,6 +510,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that is_file_removable returns correctly for an empty file.
*
* @covers ::is_file_removable
* @covers ::<!public>
*/
public function test_is_file_removable_empty() {
$filecontent = '';
@ -471,6 +526,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that is_file_removable returns false if the file is still in use.
*
* @covers ::is_file_removable
* @covers ::<!public>
*/
public function test_is_file_removable_in_use() {
$this->resetAfterTest();
@ -493,6 +551,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that is_file_removable returns false if the file is not in use.
*
* @covers ::is_file_removable
* @covers ::<!public>
*/
public function test_is_file_removable_not_in_use() {
$this->resetAfterTest();
@ -515,6 +576,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of get_content.
*
* @covers ::get_content
* @covers ::<!public>
*/
public function test_get_content() {
global $CFG;
@ -538,6 +602,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test the stock implementation of get_content.
*
* @covers ::get_content
* @covers ::<!public>
*/
public function test_get_content_empty() {
global $CFG;
@ -559,6 +626,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the list_files function requires a local copy of the
* file, and passes the path to the packer.
*
* @covers ::list_files
* @covers ::<!public>
*/
public function test_list_files() {
$filecontent = 'example content';
@ -589,6 +659,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the extract_to_pathname function requires a local copy of the
* file, and passes the path to the packer.
*
* @covers ::extract_to_pathname
* @covers ::<!public>
*/
public function test_extract_to_pathname() {
$filecontent = 'example content';
@ -620,6 +693,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the extract_to_storage function requires a local copy of the
* file, and passes the path to the packer.
*
* @covers ::extract_to_storage
* @covers ::<!public>
*/
public function test_extract_to_storage() {
$filecontent = 'example content';
@ -660,6 +736,8 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the add_storedfile_to_archive function requires a local copy of the
* file, and passes the path to the archive.
*
* @covers ::<!public>
*/
public function test_add_storedfile_to_archive_directory() {
$file = $this->get_stored_file('', '.');
@ -695,6 +773,8 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the add_storedfile_to_archive function requires a local copy of the
* file, and passes the path to the archive.
*
* @covers ::<!public>
*/
public function test_add_storedfile_to_archive_file() {
$file = $this->get_stored_file('example content');
@ -734,6 +814,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that the add_to_curl_request function requires a local copy of the
* file, and passes the path to curl_file_create.
*
* @covers ::add_to_curl_request
* @covers ::<!public>
*/
public function test_add_to_curl_request() {
$file = $this->get_stored_file('example content');
@ -756,6 +839,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that test_get_imageinfo_not_image returns false if the file
* passed was deemed to not be an image.
*
* @covers ::get_imageinfo
* @covers ::<!public>
*/
public function test_get_imageinfo_not_image() {
$filecontent = 'example content';
@ -775,6 +861,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that test_get_imageinfo_not_image returns imageinfo.
*
* @covers ::get_imageinfo
* @covers ::<!public>
*/
public function test_get_imageinfo() {
$filepath = '/path/to/file';
@ -809,6 +898,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that is_image_from_storedfile always returns false for an
* empty file size.
*
* @covers ::is_image_from_storedfile
* @covers ::<!public>
*/
public function test_is_image_empty_filesize() {
$filecontent = 'example content';
@ -829,6 +921,8 @@ class core_files_file_system_testcase extends advanced_testcase {
* @dataProvider is_image_from_storedfile_provider
* @param string $mimetype Mimetype to test
* @param bool $isimage Whether this mimetype should be detected as an image
* @covers ::is_image_from_storedfile
* @covers ::<!public>
*/
public function test_is_image_from_storedfile_mimetype($mimetype, $isimage) {
$filecontent = 'example content';
@ -845,6 +939,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that get_imageinfo_from_path returns an appropriate response
* for an image.
*
* @covers ::get_imageinfo_from_path
* @covers ::<!public>
*/
public function test_get_imageinfo_from_path() {
$filepath = __DIR__ . "/fixtures/testimage.jpg";
@ -865,6 +962,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that get_imageinfo_from_path returns an appropriate response
* for a file which is not an image.
*
* @covers ::get_imageinfo_from_path
* @covers ::<!public>
*/
public function test_get_imageinfo_from_path_no_image() {
$filepath = __FILE__;
@ -881,6 +981,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that get_content_file_handle returns a valid file handle.
*
* @covers ::get_content_file_handle
* @covers ::<!public>
*/
public function test_get_content_file_handle_default() {
$filecontent = 'example content';
@ -899,6 +1002,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that get_content_file_handle returns a valid file handle for a gz file.
*
* @covers ::get_content_file_handle
* @covers ::<!public>
*/
public function test_get_content_file_handle_gz() {
$filecontent = 'example content';
@ -916,6 +1022,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Ensure that get_content_file_handle returns an exception when calling for a invalid file handle type.
*
* @covers ::get_content_file_handle
* @covers ::<!public>
*/
public function test_get_content_file_handle_invalid() {
$filecontent = 'example content';
@ -932,6 +1041,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_hash returns the correct mimetype with
* a file whose filename suggests mimetype.
*
* @covers ::mimetype_from_hash
* @covers ::<!public>
*/
public function test_mimetype_from_hash_using_filename() {
$filepath = '/path/to/file/not/currently/on/disk';
@ -949,6 +1061,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_hash returns the correct mimetype with
* a locally available file whose filename does not suggest mimetype.
*
* @covers ::mimetype_from_hash
* @covers ::<!public>
*/
public function test_mimetype_from_hash_using_file_content() {
$filecontent = 'example content';
@ -966,6 +1081,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_hash returns the correct mimetype with
* a remotely available file whose filename does not suggest mimetype.
*
* @covers ::mimetype_from_hash
* @covers ::<!public>
*/
public function test_mimetype_from_hash_using_file_content_remote() {
$filepath = '/path/to/file/not/currently/on/disk';
@ -992,6 +1110,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_storedfile returns the correct mimetype with
* a file whose filename suggests mimetype.
*
* @covers ::mimetype_from_storedfile
* @covers ::<!public>
*/
public function test_mimetype_from_storedfile_empty() {
$file = $this->get_stored_file('');
@ -1004,6 +1125,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_storedfile returns the correct mimetype with
* a file whose filename suggests mimetype.
*
* @covers ::mimetype_from_storedfile
* @covers ::<!public>
*/
public function test_mimetype_from_storedfile_using_filename() {
$filepath = '/path/to/file/not/currently/on/disk';
@ -1019,6 +1143,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_storedfile returns the correct mimetype with
* a locally available file whose filename does not suggest mimetype.
*
* @covers ::mimetype_from_storedfile
* @covers ::<!public>
*/
public function test_mimetype_from_storedfile_using_file_content() {
$filepath = __DIR__ . "/fixtures/testimage.jpg";
@ -1034,6 +1161,9 @@ class core_files_file_system_testcase extends advanced_testcase {
/**
* Test that mimetype_from_storedfile returns the correct mimetype with
* a remotely available file whose filename does not suggest mimetype.
*
* @covers ::mimetype_from_storedfile
* @covers ::<!public>
*/
public function test_mimetype_from_storedfile_using_file_content_remote() {
$filepath = __DIR__ . "/fixtures/testimage.jpg";