diff --git a/reportbuilder/classes/local/helpers/report.php b/reportbuilder/classes/local/helpers/report.php index b7110c16e70..7ee0a080265 100644 --- a/reportbuilder/classes/local/helpers/report.php +++ b/reportbuilder/classes/local/helpers/report.php @@ -220,10 +220,10 @@ class report { throw new invalid_parameter_exception('Invalid column'); } - return $column - ->set('sortenabled', $enabled) - ->set('sortdirection', $direction) - ->update(); + return $column->set_many([ + 'sortenabled' => $enabled, + 'sortdirection' => $direction, + ])->update(); } /** diff --git a/reportbuilder/tests/helpers.php b/reportbuilder/tests/helpers.php index 3edbe3d0238..c55394ca3b6 100644 --- a/reportbuilder/tests/helpers.php +++ b/reportbuilder/tests/helpers.php @@ -61,7 +61,8 @@ abstract class core_reportbuilder_testcase extends advanced_testcase { } /** - * Stress test a report source by iterating over all it's columns and asserting we can create a report for each + * Stress test a report source by iterating over all it's columns, enabling sorting where possible and asserting we can + * create a report for each * * @param string $source */ @@ -74,10 +75,14 @@ abstract class core_reportbuilder_testcase extends advanced_testcase { $instance = manager::get_report_from_persistent($report); // Iterate over each available column, ensure each works correctly independent of any others. - $columnidentifiers = array_keys($instance->get_columns()); - foreach ($columnidentifiers as $columnidentifier) { + foreach ($instance->get_columns() as $columnidentifier => $columninstance) { $column = report::add_report_column($report->get('id'), $columnidentifier); + // Enable sorting of the column where possible. + if ($columninstance->get_is_sortable()) { + report::toggle_report_column_sorting($report->get('id'), $column->get('id'), true, SORT_DESC); + } + // We are only asserting the report returns content without errors, not the content itself. try { $content = $this->get_custom_report_content($report->get('id')); diff --git a/reportbuilder/upgrade.txt b/reportbuilder/upgrade.txt index 35c38c6fb7f..2bc3dec0b5a 100644 --- a/reportbuilder/upgrade.txt +++ b/reportbuilder/upgrade.txt @@ -1,7 +1,12 @@ This file describes API changes in /reportbuilder/* Information provided here is intended especially for developers. +=== 4.1.1 === + +* The `datasource_stress_test_columns` test helper now enables sorting on those columns that support it + === 4.1 === + * New method `add_action_divider()` in base system report class, to allow adding a divider to the action menu. * New external method `core_reportbuilder_set_filters` for setting report filter values (plus `setFilters` AJAX repository export for calling from Javascript modules)