Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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

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: 2089 lines (84 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

filelib_test:: (39 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_file_save_draft_area_files_itemid_cannot_be_false()
  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()
  test_file_prepare_standard_editor_clean_text()
  test_file_get_typegroup()
  file_get_typegroup_provider()

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


Class: filelib_test  - X-Ref

Unit tests for /lib/filelib.php.

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_file_save_draft_area_files_itemid_cannot_be_false()   X-Ref
Testing deleting file_save_draft_area_files won't accidentally wipe unintended files.


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


test_file_prepare_standard_editor_clean_text()   X-Ref
Test text cleaning when preparing text editor data.


test_file_get_typegroup(string|array $group,string $expected,)   X-Ref
Tests for file_get_typegroup to check that both arrays, and string values are accepted.

param: string|array $group
param: string $expected

file_get_typegroup_provider()   X-Ref
No description

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