Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

Unit tests for /lib/filelib.php.

Copyright: 2009 Jerome Mouneyrac
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 1779 lines (73 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

core_filelib_testcase:: (35 methods):
  test_format_postdata_for_curlcall()
  test_download_file_content()
  test_curl_basics()
  test_curl_basics_with_security_helper()
  test_curl_redirects()
  test_curl_blocked_redirect()
  test_curl_relative_redirects()
  test_curl_proxybypass()
  test_duplicate_curl_header()
  test_curl_post()
  test_curl_file()
  test_curl_file_name()
  test_curl_protocols()
  test_prepare_draft_area()
  test_delete_original_file_from_draft()
  test_ignore_file_merging_in_draft_area()
  test_curl_strip_double_headers()
  test_get_mimetype_description()
  test_get_mimetypes_array()
  test_get_mimetype_for_sending()
  test_curl_useragent()
  test_file_rewrite_pluginfile_urls()
  test_file_rewrite_pluginfile_urls_includetoken()
  test_file_rewrite_pluginfile_urls_includetoken_no_slashargs()
  create_draft_file()
  test_file_merge_files_from_draft_area_into_filearea()
  test_file_merge_files_from_draft_area_into_filearea_max_area_bytes()
  test_file_merge_files_from_draft_area_into_filearea_max_file_bytes()
  test_file_merge_files_from_draft_area_into_filearea_max_files()
  test_file_get_draft_area_info()
  test_file_get_file_area_info()
  test_file_remove_editor_orphaned_files()
  test_file_get_all_files_in_draftarea()
  test_file_copy_file_to_file_area()
  test_file_is_draft_areas_limit_reached()

testable_curl:: (5 methods):
  get_options()
  set_options()
  set_option()
  unset_option()
  call_apply_opt()


Class: core_filelib_testcase  - X-Ref

test_format_postdata_for_curlcall()   X-Ref
No description

test_download_file_content()   X-Ref
No description

test_curl_basics()   X-Ref
Test curl basics.


test_curl_basics_with_security_helper()   X-Ref
Test a curl basic request with security enabled.


test_curl_redirects()   X-Ref
No description

test_curl_blocked_redirect()   X-Ref
Test that redirects to blocked hosts are blocked.


test_curl_relative_redirects()   X-Ref
No description

test_curl_proxybypass()   X-Ref
No description

test_duplicate_curl_header()   X-Ref
Test that duplicate lines in the curl header are removed.


test_curl_post()   X-Ref
No description

test_curl_file()   X-Ref
No description

test_curl_file_name()   X-Ref
No description

test_curl_protocols()   X-Ref
No description

test_prepare_draft_area()   X-Ref
Testing prepare draft area


test_delete_original_file_from_draft()   X-Ref
Testing deleting original files.


test_ignore_file_merging_in_draft_area()   X-Ref
Test avoid file merging when working with draft areas.


test_curl_strip_double_headers()   X-Ref
Tests the strip_double_headers function in the curl class.


test_get_mimetype_description()   X-Ref
Tests the get_mimetype_description function.


test_get_mimetypes_array()   X-Ref
Tests the get_mimetypes_array function.


test_get_mimetype_for_sending()   X-Ref
Tests for get_mimetype_for_sending function.


test_curl_useragent()   X-Ref
Test curl agent settings.


test_file_rewrite_pluginfile_urls()   X-Ref
Test file_rewrite_pluginfile_urls.


test_file_rewrite_pluginfile_urls_includetoken()   X-Ref
Test file_rewrite_pluginfile_urls with includetoken.


test_file_rewrite_pluginfile_urls_includetoken_no_slashargs()   X-Ref
Test file_rewrite_pluginfile_urls with includetoken with slasharguments disabled..


create_draft_file($filedata = array()   X-Ref
Helpter function to create draft files

param: array  $filedata data for the file record (to not use defaults)
return: stored_file the stored file instance

test_file_merge_files_from_draft_area_into_filearea()   X-Ref
Test file_merge_files_from_draft_area_into_filearea


test_file_merge_files_from_draft_area_into_filearea_max_area_bytes()   X-Ref
Test max area bytes for file_merge_files_from_draft_area_into_filearea


test_file_merge_files_from_draft_area_into_filearea_max_file_bytes()   X-Ref
Test max file bytes for file_merge_files_from_draft_area_into_filearea


test_file_merge_files_from_draft_area_into_filearea_max_files()   X-Ref
Test max file number for file_merge_files_from_draft_area_into_filearea


test_file_get_draft_area_info()   X-Ref
Test file_get_draft_area_info.


test_file_get_file_area_info()   X-Ref
Test file_get_file_area_info.


test_file_remove_editor_orphaned_files()   X-Ref
Test confirming that draft files not referenced in the editor text are removed.


test_file_get_all_files_in_draftarea()   X-Ref
Test that all files in the draftarea are returned.


test_file_copy_file_to_file_area()   X-Ref
No description

test_file_is_draft_areas_limit_reached()   X-Ref
Test file_is_draft_areas_limit_reached


Class: testable_curl  - X-Ref

Test-specific class to allow easier testing of curl functions.

get_options()   X-Ref
Accessor for private options array using reflection.

return: array

set_options($options)   X-Ref
Setter for private options array using reflection.

param: array $options

set_option($option, $value)   X-Ref
Setter for individual option.

param: string $option
param: string $value

unset_option($option)   X-Ref
Unsets an option on the curl object

param: string $option

call_apply_opt($options = null)   X-Ref
Wrapper to access the private curl::apply_opt() method using reflection.

param: array $options
return: resource The curl handle