Search moodle.org's
Developer Documentation

See Release Notes

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

(no description)

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

Defines 1 class


Class: entries_import_test  - X-Ref

Unit tests for import.php.

setUp()   X-Ref
Set up function.


get_test_data()   X-Ref
Get the test data.
In this instance we are setting up database records to be used in the unit tests.

return: array

test_import()   X-Ref
Test uploading entries for a data instance without userdata.


test_import_with_userdata()   X-Ref
Test uploading entries for a data instance with userdata.

At least one entry has an identifiable user, which is assigned as author.


test_import_with_field_username()   X-Ref
Test uploading entries for a data instance with userdata and a defined field 'Username'.

This should test the corner case, in which a user has defined a data fields, which has the same name
as the current lang string for username. In that case, the first Username entry is used for the field.
The second one is used to identify the author.


test_import_with_field_username_without_userdata()   X-Ref
Test uploading entries for a data instance with a field 'Username' but only one occurrence in the csv file.

This should test the corner case, in which a user has defined a data fields, which has the same name
as the current lang string for username. In that case, the only Username entry is used for the field.
The author should not be set.


test_import_with_files()   X-Ref
Tests the import including files from a zip archive.

return: void

test_import_with_files_missing_file()   X-Ref
Tests the import including files from a zip archive.

return: void

get_data_records(int $dataid)   X-Ref
Returns the records of the data instance.

Each records has an item entry, which contains all fields associated with this item.
Each fields has the parameters name, type and content.

param: int $dataid Id of the data instance.
return: array The records of the data instance.

test_get_added_record_messages(string $datafilecontent, int $expectedcount)   X-Ref
Tests if the amount of imported records is counted properly.

param: string $datafilecontent the content of the datafile to test as string
param: int $expectedcount the expected count of messages depending on the datafile content

get_added_record_messages_provider()   X-Ref
Data provider method for self::test_get_added_record_messages.

return: array data for testing