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 39 and 311]

(no description)

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

Defines 1 class


Class: 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.

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.