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 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

File Size: 1251 lines (44 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

file_system_test:: (56 methods):
  setUp()
  tearDown()
  setup_vfile_root()
  get_stored_file()
  get_testable_mock()
  test_not_cloneable()
  test_default_class()
  test_supplied_class()
  test_readfile_remote()
  test_readfile_local()
  test_get_local_path_from_storedfile()
  test_get_remote_path_from_storedfile()
  test_is_file_readable_locally_by_hash()
  test_is_file_readable_locally_by_hash_empty()
  test_is_file_readable_remotely_by_hash()
  test_is_file_readable_remotely_by_hash_empty()
  test_is_file_readable_remotely_by_hash_not_found()
  test_is_file_readable_remotely_by_storedfile()
  test_is_file_readable_remotely_by_storedfile_empty()
  test_is_file_readable_locally_by_storedfile_empty()
  test_is_file_readable_remotely_by_storedfile_not_found()
  test_is_file_readable_locally_by_storedfile_unreadable()
  test_is_file_readable_locally_by_storedfile_passes_fetch()
  test_is_file_removable_empty()
  test_is_file_removable_in_use()
  test_is_file_removable_not_in_use()
  test_get_content()
  test_get_content_empty()
  test_list_files()
  test_extract_to_pathname()
  test_extract_to_storage()
  test_add_storedfile_to_archive_directory()
  test_add_storedfile_to_archive_file()
  test_add_to_curl_request()
  test_get_imageinfo_not_image()
  test_get_imageinfo()
  test_is_image_empty_filesize()
  test_is_image_from_storedfile_mimetype()
  test_get_imageinfo_from_path()
  test_get_imageinfo_from_path_no_image()
  test_get_imageinfo_from_path_svg_viewbox()
  test_get_imageinfo_from_path_svg_with_width_height()
  test_get_imageinfo_from_path_svg_without_attribute()
  test_get_imageinfo_from_path_svg_invalid()
  test_get_content_file_handle_default()
  test_get_content_file_handle_gz()
  test_get_content_file_handle_invalid()
  test_mimetype_from_hash_using_filename()
  test_mimetype_from_hash_using_file_content()
  test_mimetype_from_hash_using_file_content_remote()
  test_mimetype_from_storedfile_empty()
  test_mimetype_from_storedfile_using_filename()
  test_mimetype_from_storedfile_using_file_content()
  test_mimetype_from_storedfile_using_file_content_remote()
  is_image_from_storedfile_provider()
  get_local_path_from_storedfile_provider()


Class: file_system_test  - X-Ref

Unit tests for file_system.

setUp()   X-Ref
No description

tearDown()   X-Ref
No description

setup_vfile_root($content = [])   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 = [])   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 abstract file_system class.

param: array   $mockedmethods A list of methods you intend to override
return: file_system

test_not_cloneable()   X-Ref
Ensure that the file system is not clonable.


test_default_class()   X-Ref
Ensure that the filedir file_system extension is used by default.


test_supplied_class()   X-Ref
Ensure that the specified file_system extension class is used.


test_readfile_remote()   X-Ref
Test that the readfile function outputs content to disk.


test_readfile_local()   X-Ref
Test that the readfile function outputs content to disk.


test_get_local_path_from_storedfile($args, $fetch)   X-Ref
Test that the get_local_path_from_storedfile function functions
correctly when called with various args.

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

test_get_remote_path_from_storedfile()   X-Ref
Ensure that the default implementation of get_remote_path_from_storedfile
simply calls get_local_path_from_storedfile without requiring a
fetch.


test_is_file_readable_locally_by_hash()   X-Ref
Test the stock implementation of is_file_readable_locally_by_hash with a valid file.

This should call get_local_path_from_hash and check the readability
of the file.

Fetching the file is optional.


test_is_file_readable_locally_by_hash_empty()   X-Ref
Test the stock implementation of is_file_readable_locally_by_hash with an empty file.


test_is_file_readable_remotely_by_hash()   X-Ref
Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.


test_is_file_readable_remotely_by_hash_empty()   X-Ref
Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.


test_is_file_readable_remotely_by_hash_not_found()   X-Ref
Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.


test_is_file_readable_remotely_by_storedfile()   X-Ref
Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.


test_is_file_readable_remotely_by_storedfile_empty()   X-Ref
Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.


test_is_file_readable_locally_by_storedfile_empty()   X-Ref
Test the stock implementation of is_file_readable_locally_by_storedfile with an empty file.


test_is_file_readable_remotely_by_storedfile_not_found()   X-Ref
Test the stock implementation of is_file_readable_remotely_by_storedfile with a valid file.


test_is_file_readable_locally_by_storedfile_unreadable()   X-Ref
Test the stock implementation of is_file_readable_locally_by_storedfile with a valid file.


test_is_file_readable_locally_by_storedfile_passes_fetch()   X-Ref
Test the stock implementation of is_file_readable_locally_by_storedfile with a valid file should pass fetch.


test_is_file_removable_empty()   X-Ref
Ensure that is_file_removable returns correctly for an empty file.


test_is_file_removable_in_use()   X-Ref
Ensure that is_file_removable returns false if the file is still in use.


test_is_file_removable_not_in_use()   X-Ref
Ensure that is_file_removable returns false if the file is not in use.


test_get_content()   X-Ref
Test the stock implementation of get_content.


test_get_content_empty()   X-Ref
Test the stock implementation of get_content.


test_list_files()   X-Ref
Ensure that the list_files function requires a local copy of the
file, and passes the path to the packer.


test_extract_to_pathname()   X-Ref
Ensure that the extract_to_pathname function requires a local copy of the
file, and passes the path to the packer.


test_extract_to_storage()   X-Ref
Ensure that the extract_to_storage function requires a local copy of the
file, and passes the path to the packer.


test_add_storedfile_to_archive_directory()   X-Ref
Ensure that the add_storedfile_to_archive function requires a local copy of the
file, and passes the path to the archive.


test_add_storedfile_to_archive_file()   X-Ref
Ensure that the add_storedfile_to_archive function requires a local copy of the
file, and passes the path to the archive.


test_add_to_curl_request()   X-Ref
Ensure that the add_to_curl_request function requires a local copy of the
file, and passes the path to curl_file_create.


test_get_imageinfo_not_image()   X-Ref
Ensure that test_get_imageinfo_not_image returns false if the file
passed was deemed to not be an image.


test_get_imageinfo()   X-Ref
Ensure that test_get_imageinfo_not_image returns imageinfo.


test_is_image_empty_filesize()   X-Ref
Ensure that is_image_from_storedfile always returns false for an
empty file size.


test_is_image_from_storedfile_mimetype($mimetype, $isimage)   X-Ref
Ensure that is_image_from_storedfile behaves correctly based on
mimetype.

param: string  $mimetype Mimetype to test
param: bool    $isimage Whether this mimetype should be detected as an image

test_get_imageinfo_from_path()   X-Ref
Test that get_imageinfo_from_path returns an appropriate response
for an image.


test_get_imageinfo_from_path_no_image()   X-Ref
Test that get_imageinfo_from_path returns an appropriate response
for a file which is not an image.


test_get_imageinfo_from_path_svg_viewbox()   X-Ref
Test that get_imageinfo_from_path returns an appropriate response
for an svg image with viewbox attribute.


test_get_imageinfo_from_path_svg_with_width_height()   X-Ref
Test that get_imageinfo_from_path returns an appropriate response
for an svg image with width and height attributes.


test_get_imageinfo_from_path_svg_without_attribute()   X-Ref
Test that get_imageinfo_from_path returns an appropriate response
for an svg image without attributes.


test_get_imageinfo_from_path_svg_invalid()   X-Ref
Test that get_imageinfo_from_path returns an appropriate response
for a file which is not an correct svg.


test_get_content_file_handle_default()   X-Ref
Ensure that get_content_file_handle returns a valid file handle.


test_get_content_file_handle_gz()   X-Ref
Ensure that get_content_file_handle returns a valid file handle for a gz file.


test_get_content_file_handle_invalid()   X-Ref
Ensure that get_content_file_handle returns an exception when calling for a invalid file handle type.


test_mimetype_from_hash_using_filename()   X-Ref
Test that mimetype_from_hash returns the correct mimetype with
a file whose filename suggests mimetype.


test_mimetype_from_hash_using_file_content()   X-Ref
Test that mimetype_from_hash returns the correct mimetype with
a locally available file whose filename does not suggest mimetype.


test_mimetype_from_hash_using_file_content_remote()   X-Ref
Test that mimetype_from_hash returns the correct mimetype with
a remotely available file whose filename does not suggest mimetype.


test_mimetype_from_storedfile_empty()   X-Ref
Test that mimetype_from_storedfile returns the correct mimetype with
a file whose filename suggests mimetype.


test_mimetype_from_storedfile_using_filename()   X-Ref
Test that mimetype_from_storedfile returns the correct mimetype with
a file whose filename suggests mimetype.


test_mimetype_from_storedfile_using_file_content()   X-Ref
Test that mimetype_from_storedfile returns the correct mimetype with
a locally available file whose filename does not suggest mimetype.


test_mimetype_from_storedfile_using_file_content_remote()   X-Ref
Test that mimetype_from_storedfile returns the correct mimetype with
a remotely available file whose filename does not suggest mimetype.


is_image_from_storedfile_provider()   X-Ref
Data Provider for is_image_from_storedfile tests.

return: array

get_local_path_from_storedfile_provider()   X-Ref
Data provider for get_local_path_from_storedfile tests.

return: array