See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 and 403]
Unit tests for file_system_filedir.
Copyright: | 2017 Andrew Nicols <andrew@nicols.co.uk> |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 1127 lines (38 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
core_files_file_system_filedir_testcase:: (39 methods):
setUp()
tearDown()
setup_vfile_root()
get_stored_file()
get_testable_mock()
test_readonly_filesystem_filedir()
test_readonly_filesystem_trashdir()
test_warnings_put_in_place()
test_get_remote_path_from_hash()
test_get_local_path_from_storedfile_with_recovery()
test_get_local_path_from_storedfile_without_recovery()
test_get_fulldir_from_hash()
test_get_fulldir_from_storedfile()
test_get_contentdir_from_hash()
test_get_contentpath_from_hash()
test_get_trash_fullpath_from_hash()
test_get_trash_fulldir_from_hash()
test_copy_content_from_storedfile()
test_recover_file()
test_recover_file_already_present()
test_recover_file_size_mismatch()
test_recover_file_has_mismatch()
test_recover_file_alttrash()
test_recover_file_contentdir_readonly()
test_add_file_from_path()
test_add_file_from_path_file_unavailable()
test_add_file_from_path_mismatched_hash()
test_add_file_from_path_existing_content_invalid()
test_add_file_from_path_existing_cannot_write_hashpath()
test_add_file_from_string()
test_add_file_from_string_existing_cannot_write_hashpath()
test_add_file_from_string_existing_matches()
test_remove_file_missing()
test_remove_file_existing_trash()
test_remove_file_empty()
test_remove_file_in_use()
test_remove_file_expired()
test_empty_trash()
contenthash_dataprovider()
Class: core_files_file_system_filedir_testcase - X-Ref
Unit tests for file_system_filedir.setUp() X-Ref |
Shared test setUp. |
tearDown() X-Ref |
Shared teset tearDown. |
setup_vfile_root($filedir = [], $trashdir = [], $sourcedir = null) X-Ref |
Helper function to help setup and configure the virtual file system stream. param: array $filedir Directory structure and content of the filedir param: array $trashdir Directory structure and content of the sourcedir param: array $sourcedir Directory structure and content of a directory used for source files for tests return: \org\bovigo\vfs\vfsStream |
get_stored_file($filecontent, $filename = null, $mockedmethods = null) X-Ref |
Helper to create a stored file objectw with the given supplied content. param: string $filecontent The content of the mocked file param: string $filename The file name to use in the stored_file param: array $mockedmethods A list of methods you intend to override return: stored_file |
get_testable_mock($mockedmethods = []) X-Ref |
Get a testable mock of the file_system_filedir class. param: array $mockedmethods A list of methods you intend to override return: file_system |
test_readonly_filesystem_filedir() X-Ref |
Ensure that an appropriate error is shown when the filedir directory is not writable. |
test_readonly_filesystem_trashdir() X-Ref |
Ensure that an appropriate error is shown when the trash directory is not writable. |
test_warnings_put_in_place() X-Ref |
Test that the standard Moodle warning message is put into the filedir. |
test_get_remote_path_from_hash() X-Ref |
Ensure that the default implementation of get_remote_path_from_hash simply calls get_local_path_from_hash. |
test_get_local_path_from_storedfile_with_recovery() X-Ref |
Test the stock implementation of get_local_path_from_storedfile_with_recovery with no file found and a failed recovery. |
test_get_local_path_from_storedfile_without_recovery() X-Ref |
Test the stock implementation of get_local_path_from_storedfile_with_recovery with no file found and a failed recovery. |
test_get_fulldir_from_hash($hash, $hashdir) X-Ref |
Test that the correct path is generated for the supplied content hashes. param: string $hash contenthash to test param: string $hashdir Expected format of content directory |
test_get_fulldir_from_storedfile($hash, $hashdir) X-Ref |
Test that the correct path is generated for the supplied content hashes when used with a stored_file. param: string $hash contenthash to test param: string $hashdir Expected format of content directory |
test_get_contentdir_from_hash($hash, $hashdir) X-Ref |
Test that the correct content directory is generated for the supplied content hashes. param: string $hash contenthash to test param: string $hashdir Expected format of content directory |
test_get_contentpath_from_hash($hash, $hashdir) X-Ref |
Test that the correct content path is generated for the supplied content hashes. param: string $hash contenthash to test param: string $hashdir Expected format of content directory |
test_get_trash_fullpath_from_hash($hash, $hashdir) X-Ref |
Test that the correct trash path is generated for the supplied content hashes. param: string $hash contenthash to test param: string $hashdir Expected format of content directory |
test_get_trash_fulldir_from_hash($hash, $hashdir) X-Ref |
Test that the correct trash directory is generated for the supplied content hashes. param: string $hash contenthash to test param: string $hashdir Expected format of content directory |
test_copy_content_from_storedfile() X-Ref |
Ensure that copying a file to a target from a stored_file works as anticipated. |
test_recover_file() X-Ref |
Ensure that content recovery works. |
test_recover_file_already_present() X-Ref |
Ensure that content recovery works. |
test_recover_file_size_mismatch() X-Ref |
Ensure that content recovery works. |
test_recover_file_has_mismatch() X-Ref |
Ensure that content recovery works. |
test_recover_file_alttrash() X-Ref |
Ensure that content recovery works when the content file is in the alt trash directory. |
test_recover_file_contentdir_readonly() X-Ref |
Test that an appropriate error message is generated when adding a file to the pool when the pool directory structure is not writable. |
test_add_file_from_path() X-Ref |
Test adding a file to the pool. |
test_add_file_from_path_file_unavailable() X-Ref |
Test that an appropriate error message is generated when adding an unavailable file to the pool is attempted. |
test_add_file_from_path_mismatched_hash() X-Ref |
Test that an appropriate error message is generated when specifying the wrong contenthash when adding a file to the pool. |
test_add_file_from_path_existing_content_invalid() X-Ref |
Test that an appropriate error message is generated when an existing file in the pool has the wrong contenthash |
test_add_file_from_path_existing_cannot_write_hashpath() X-Ref |
Test that an appropriate error message is generated when adding a file to the pool when the pool directory structure is not writable. |
test_add_file_from_string() X-Ref |
Test adding a string to the pool. |
test_add_file_from_string_existing_cannot_write_hashpath() X-Ref |
Test that an appropriate error message is generated when adding a string to the pool when the pool directory structure is not writable. |
test_add_file_from_string_existing_matches() X-Ref |
Test adding a string to the pool when an item with the same contenthash is already present. |
test_remove_file_missing() X-Ref |
Test the cleanup of deleted files when there are no files to delete. |
test_remove_file_existing_trash() X-Ref |
Test the cleanup of deleted files when a file already exists in the trash for that path. |
test_remove_file_empty() X-Ref |
Ensure that remove_file does nothing with an empty file. |
test_remove_file_in_use() X-Ref |
Ensure that remove_file does nothing when a file is still in use. |
test_remove_file_expired() X-Ref |
Ensure that remove_file removes the file when it is no longer in use. |
test_empty_trash() X-Ref |
Test purging the cache. |
contenthash_dataprovider() X-Ref |
Data Provider for contenthash to contendir conversion. return: array |