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.

Class: column_test  - X-Ref

Unit tests for a report column

test_name()   X-Ref
Test column name getter/setter


test_title()   X-Ref
Test column title getter/setter


test_get_entity_name()   X-Ref
Test entity name getter


test_get_unique_identifier()   X-Ref
Test getting unique identifier


test_type()   X-Ref
Test column type getter/setter


test_type_default()   X-Ref
Test column default type


test_type_invalid()   X-Ref
Test column type with invalid value


test_add_join()   X-Ref
Test adding single join


test_add_joins()   X-Ref
Test adding multiple joins


add_field_provider()   X-Ref
Data provider for {@see test_add_field}

return: array

test_add_field(string $sql, string $alias, array $expectedselect)   X-Ref
Test adding single field, and retrieving it

param: string $sql
param: string $alias
param: array $expectedselect

test_add_field_with_params()   X-Ref
Test adding params to field, and retrieving them


test_add_field_alias_in_sql()   X-Ref
Test adding field with alias as part of SQL throws an exception


test_add_field_complex_without_alias()   X-Ref
Test adding field with complex SQL without an alias throws an exception


add_fields_provider()   X-Ref
Data provider for {@see test_add_fields}

return: array

test_add_fields(string $sql, array $expectedselect)   X-Ref
Test adding fields to a column, and retrieving them

param: string $sql
param: array $expectedselect

test_column_alias()   X-Ref
Test column alias


test_column_alias_with_field_alias()   X-Ref
Test column alias with a field containing an alias


test_column_alias_no_fields()   X-Ref
Test alias of column without any fields throws exception


test_set_groupby_sql()   X-Ref
Test setting column group by SQL


test_get_groupby_sql()   X-Ref
Test getting default column group by SQL


column_type_provider()   X-Ref
Data provider for {@see test_get_default_value} and {@see test_format_value}

return: array[]

test_get_default_value(int $columntype, $value, $expected = null)   X-Ref
Test default value is returned from selected values, with correct type

param: int $columntype
param: mixed $value
param: mixed|null $expected Expected value, or null to indicate it should be identical to value

test_format_value(int $columntype, $value, $expected = null)   X-Ref
Test that column value is returned correctly, with correct type

param: int $columntype
param: mixed $value
param: mixed|null $expected Expected value, or null to indicate it should be identical to value

test_format_value_callback()   X-Ref
Test that column value with callback is returned


test_format_value_callback_fields()   X-Ref
Test that column value with callback (using all fields) is returned


test_format_value_callback_arguments()   X-Ref
Test that column value with callback (using arguments) is returned


test_format_value_callback_aggregation()   X-Ref
Test that column value with callback (where aggregation is not set) is returned


test_add_multiple_callback()   X-Ref
Test adding multiple callbacks to a column


test_set_callback()   X-Ref
Test that setting column callback overwrites previous callbacks


test_is_sortable()   X-Ref
Test is sortable


test_get_sortfields()   X-Ref
Test retrieving sort fields


test_get_sortfields_with_field_alias()   X-Ref
Test retrieving sort fields when an aliased field is set as sortable


test_get_sortfields_unknown_field()   X-Ref
Test retrieving sort fields when an unknown field is set as sortable


test_is_available()   X-Ref
Test is available


create_column(string $name, ?lang_string $title = null, string $entityname = 'column_testcase')   X-Ref
Helper method to create a column instance

param: string $name
param: lang_string|null $title
param: string $entityname
return: column