Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

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
File Size: 2196 lines (83 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

file_storage_test:: (72 methods):
  test_create_file_from_string()
  test_create_file_from_pathname()
  test_get_file()
  test_get_file_preview()
  test_get_file_preview_nonimage()
  test_file_renaming()
  test_create_file_from_reference()
  test_create_file_from_reference_with_content_hash()
  setup_three_private_files()
  test_get_area_files()
  test_get_area_tree()
  test_get_file_by_id()
  test_get_file_by_hash()
  test_get_external_files()
  test_create_directory_contextid_negative()
  test_create_directory_contextid_invalid()
  test_create_directory_component_invalid()
  test_create_directory_filearea_invalid()
  test_create_directory_itemid_negative()
  test_create_directory_itemid_invalid()
  test_create_directory_filepath_invalid()
  test_get_directory_files()
  test_search_references()
  test_delete_area_files()
  test_delete_area_files_itemid()
  test_delete_area_files_select()
  test_delete_component_files()
  test_create_file_from_url()
  test_cron()
  test_is_area_empty()
  test_move_area_files_to_new_context()
  test_convert_image()
  test_convert_image_png()
  generate_file_record()
  test_create_file_from_storedfile_file_invalid()
  test_create_file_from_storedfile_contextid_invalid()
  test_create_file_from_storedfile_component_invalid()
  test_create_file_from_storedfile_filearea_invalid()
  test_create_file_from_storedfile_itemid_invalid()
  test_create_file_from_storedfile_filepath_invalid()
  test_create_file_from_storedfile_filename_invalid()
  test_create_file_from_storedfile_timecreated_invalid()
  test_create_file_from_storedfile_timemodified_invalid()
  test_create_file_from_storedfile_duplicate()
  test_create_file_from_storedfile()
  test_create_file_from_string_contextid_invalid()
  test_create_file_from_string_component_invalid()
  test_create_file_from_string_filearea_invalid()
  test_create_file_from_string_itemid_invalid()
  test_create_file_from_string_filepath_invalid()
  test_create_file_from_string_filename_invalid()
  test_create_file_from_string_timecreated_invalid()
  test_create_file_from_string_timemodified_invalid()
  test_create_file_from_string_duplicate()
  test_create_file_from_pathname_contextid_invalid()
  test_create_file_from_pathname_component_invalid()
  test_create_file_from_pathname_filearea_invalid()
  test_create_file_from_pathname_itemid_invalid()
  test_create_file_from_pathname_filepath_invalid()
  test_create_file_from_pathname_filename_invalid()
  test_create_file_from_pathname_timecreated_invalid()
  test_create_file_from_pathname_timemodified_invalid()
  test_create_file_from_pathname_duplicate_file()
  test_delete_reference_on_nonreference()
  test_delete_reference_one_symlink_does_not_rule_them_all()
  test_update_reference_internal()
  test_get_unused_filename()
  test_mimetype_not_found()
  filepath_mimetype_provider()
  test_mimetype_known()
  test_mimetype_from_file_not_found()
  test_mimetype_from_file_known()

test_stored_file_inspection:: (1 method):
  get_pretected_pathname()


Class: file_storage_test  - X-Ref

Unit tests for /lib/filestorage/file_storage.php

test_create_file_from_string()   X-Ref
Files can be created from strings.


test_create_file_from_pathname()   X-Ref
Local files can be added to the filepool


test_get_file()   X-Ref
Tests get get file.


test_get_file_preview(stored_file $file)   X-Ref
Local images can be added to the filepool and their preview can be obtained

param: stored_file $file

test_get_file_preview_nonimage()   X-Ref
Tests for get_file_preview without an image.


test_file_renaming()   X-Ref
Make sure renaming is working


test_create_file_from_reference()   X-Ref
Create file from reference tests


test_create_file_from_reference_with_content_hash()   X-Ref
Create file from reference tests


setup_three_private_files()   X-Ref
No description

test_get_area_files()   X-Ref
Tests for get_area_files


test_get_area_tree()   X-Ref
Tests for get_area_tree


test_get_file_by_id()   X-Ref
Tests for get_file_by_id


test_get_file_by_hash()   X-Ref
Tests for get_file_by_hash


test_get_external_files()   X-Ref
Tests for get_external_files


test_create_directory_contextid_negative()   X-Ref
Tests for create_directory with a negative contextid.


test_create_directory_contextid_invalid()   X-Ref
Tests for create_directory with an invalid contextid.


test_create_directory_component_invalid()   X-Ref
Tests for create_directory with an invalid component.


test_create_directory_filearea_invalid()   X-Ref
Tests for create_directory with an invalid filearea.


test_create_directory_itemid_negative()   X-Ref
Tests for create_directory with a negative itemid


test_create_directory_itemid_invalid()   X-Ref
Tests for create_directory with an invalid itemid


test_create_directory_filepath_invalid()   X-Ref
Tests for create_directory with an invalid filepath


test_get_directory_files()   X-Ref
Tests for get_directory_files.


test_search_references()   X-Ref
Tests for search_references.


test_delete_area_files()   X-Ref
Tests for delete_area_files.


test_delete_area_files_itemid()   X-Ref
Tests for delete_area_files using an itemid.


test_delete_area_files_select()   X-Ref
Tests for delete_area_files_select.


test_delete_component_files()   X-Ref
Tests for delete_component_files.


test_create_file_from_url()   X-Ref
Tests for create_file_from_url.


test_cron()   X-Ref
Tests for cron.


test_is_area_empty()   X-Ref
Tests for is_area_empty.


test_move_area_files_to_new_context()   X-Ref
Tests for move_area_files_to_new_context.


test_convert_image()   X-Ref
Tests for convert_image.


test_convert_image_png()   X-Ref
Tests for convert_image with a PNG.


generate_file_record()   X-Ref
No description

test_create_file_from_storedfile_file_invalid()   X-Ref


test_create_file_from_storedfile_contextid_invalid()   X-Ref


test_create_file_from_storedfile_component_invalid()   X-Ref


test_create_file_from_storedfile_filearea_invalid()   X-Ref


test_create_file_from_storedfile_itemid_invalid()   X-Ref


test_create_file_from_storedfile_filepath_invalid()   X-Ref


test_create_file_from_storedfile_filename_invalid()   X-Ref


test_create_file_from_storedfile_timecreated_invalid()   X-Ref


test_create_file_from_storedfile_timemodified_invalid()   X-Ref


test_create_file_from_storedfile_duplicate()   X-Ref


test_create_file_from_storedfile()   X-Ref
Tests for create_file_from_storedfile.


test_create_file_from_string_contextid_invalid()   X-Ref


test_create_file_from_string_component_invalid()   X-Ref


test_create_file_from_string_filearea_invalid()   X-Ref


test_create_file_from_string_itemid_invalid()   X-Ref


test_create_file_from_string_filepath_invalid()   X-Ref


test_create_file_from_string_filename_invalid()   X-Ref


test_create_file_from_string_timecreated_invalid()   X-Ref


test_create_file_from_string_timemodified_invalid()   X-Ref


test_create_file_from_string_duplicate()   X-Ref
Tests for create_file_from_string with a duplicate string.


test_create_file_from_pathname_contextid_invalid()   X-Ref


test_create_file_from_pathname_component_invalid()   X-Ref


test_create_file_from_pathname_filearea_invalid()   X-Ref


test_create_file_from_pathname_itemid_invalid()   X-Ref


test_create_file_from_pathname_filepath_invalid()   X-Ref


test_create_file_from_pathname_filename_invalid()   X-Ref


test_create_file_from_pathname_timecreated_invalid()   X-Ref


test_create_file_from_pathname_timemodified_invalid()   X-Ref


test_create_file_from_pathname_duplicate_file()   X-Ref


test_delete_reference_on_nonreference()   X-Ref
Calling \stored_file::delete_reference() on a non-reference file throws coding_exception


test_delete_reference_one_symlink_does_not_rule_them_all()   X-Ref
Calling \stored_file::delete_reference() on a reference file does not affect other
symlinks to the same original


test_update_reference_internal()   X-Ref
Make sure that when internal file is updated all references to it are
updated immediately. When it is deleted, the references are converted
to true copies.


test_get_unused_filename()   X-Ref
Tests for get_unused_filename.


test_mimetype_not_found()   X-Ref
Test that mimetype_from_file returns appropriate output when the
file could not be found.


filepath_mimetype_provider()   X-Ref
Data provider to return fixture files and their expected mimetype

return: array[]

test_mimetype_known(string $filepath, string $expectedmimetype)   X-Ref
Test that mimetype returns appropriate output for a known file.

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.

param: string $filepath
param: string $expectedmimetype

test_mimetype_from_file_not_found()   X-Ref
Test that mimetype_from_file returns appropriate output when the
file could not be found.


test_mimetype_from_file_known(string $filepath, string $expectedmimetype)   X-Ref
Test that mimetype_from_file returns appropriate output for a known
file.

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.

param: string $filepath
param: string $expectedmimetype

Class: test_stored_file_inspection  - X-Ref

get_pretected_pathname(stored_file $file)   X-Ref
No description