Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Class: fields_test  - X-Ref

Unit tests for \core_user\fields

test_get_picture_fields()   X-Ref
Tests getting the user picture fields.


test_get_name_fields()   X-Ref
Tests getting the user name fields.


test_get_identity_fields()   X-Ref
Tests getting the identity fields.


test_get_identity_fields_invalid()   X-Ref
Test getting identity fields, when one of them refers to a non-existing custom profile field


test_get_required_fields()   X-Ref
Tests the get_required_fields function.

This function composes the results of get_identity/name/picture_fields, so we are not going
to test the details of the identity permissions as that was already covered. Just how they
are included/combined.

test_get_required_fields_limitpurposes()   X-Ref
Tests the get_required_fields function when you use the $limitpurposes parameter.


test_get_required_fields_limitpurposes_not_in_constructor()   X-Ref
There should be an exception if you try to 'limit' purposes to one that wasn't even included.


init_for_sql_tests()   X-Ref
Sets up data and a fields object for all the get_sql tests.

return: fields Constructed fields object for testing

test_get_sql_variations()   X-Ref
Tests getting SQL (and actually using it).


test_get_sql_multiple()   X-Ref
Tests what happens if you use the SQL multiple times in a query (i.e. that it correctly
creates the different identifiers).


test_get_sql_nothing()   X-Ref
Tests the get_sql function when there are no fields to retrieve.


test_get_sql_no_custom_fields()   X-Ref
Tests get_sql when there are no custom fields; in this scenario, the joins and joinparams
are always blank.


test_get_sql_selects_format()   X-Ref
Tests the format of the $selects string, which is important particularly for backward
compatibility.


get_sql_fullname_provider()   X-Ref
Data provider for {@see test_get_sql_fullname}

return: array

test_get_sql_fullname(string $fullnamedisplay, string $expectedfullname)   X-Ref
Test sql_fullname_display method with various fullname formats

param: string $fullnamedisplay
param: string $expectedfullname

test_get_sql_fullname_null_field()   X-Ref
Test sql_fullname_display when one of the configured name fields is null