diff --git a/badges/tests/reportbuilder/datasource/badges_test.php b/badges/tests/reportbuilder/datasource/badges_test.php index e9edd051d8c..cacf1896187 100644 --- a/badges/tests/reportbuilder/datasource/badges_test.php +++ b/badges/tests/reportbuilder/datasource/badges_test.php @@ -72,16 +72,13 @@ class badges_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Badges', 'source' => badges::class, 'default' => 0]); // Badge course. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname']) - ->set_many(['sortenabled' => true, 'sortdirection' => SORT_ASC])->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname', 'sortenabled' => 1]); // Badge name. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'badge:name']) - ->set_many(['sortenabled' => true, 'sortdirection' => SORT_ASC])->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'badge:name', 'sortenabled' => 1]); // User fullname. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname']) - ->set_many(['sortenabled' => true, 'sortdirection' => SORT_ASC])->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname', 'sortenabled' => 1]); $content = $this->get_custom_report_content($report->get('id')); $this->assertCount(3, $content); diff --git a/course/tests/reportbuilder/datasource/participants_test.php b/course/tests/reportbuilder/datasource/participants_test.php index d703bff8027..25025ae0191 100644 --- a/course/tests/reportbuilder/datasource/participants_test.php +++ b/course/tests/reportbuilder/datasource/participants_test.php @@ -97,10 +97,7 @@ class participants_test extends core_reportbuilder_testcase { $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname']); // Order by enrolment method. - $generator->create_column(['reportid' => $report->get('id'), - 'uniqueidentifier' => 'enrolment:method']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'enrolment:method', 'sortenabled' => 1]); $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'group:name']); $generator->create_column(['reportid' => $report->get('id'), diff --git a/group/tests/reportbuilder/datasource/groups_test.php b/group/tests/reportbuilder/datasource/groups_test.php index 2338babc7d6..8f32bd1924f 100644 --- a/group/tests/reportbuilder/datasource/groups_test.php +++ b/group/tests/reportbuilder/datasource/groups_test.php @@ -86,8 +86,7 @@ class groups_test extends core_reportbuilder_testcase { $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname']); $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'grouping:name']); - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'group:name']) - ->set('sortenabled', true)->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'group:name', 'sortenabled' => 1]); $content = $this->get_custom_report_content($report->get('id')); $this->assertCount(2, $content); diff --git a/reportbuilder/tests/external/custom_report_data_exporter_test.php b/reportbuilder/tests/external/custom_report_data_exporter_test.php index 4bd1302a3c0..5e2d9476177 100644 --- a/reportbuilder/tests/external/custom_report_data_exporter_test.php +++ b/reportbuilder/tests/external/custom_report_data_exporter_test.php @@ -48,8 +48,12 @@ class custom_report_data_exporter_test extends advanced_testcase { $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder'); $report = $generator->create_report(['name' => 'My report', 'source' => users::class, 'default' => false]); - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname']) - ->set_many(['heading' => 'Lovely user', 'sortenabled' => true])->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:fullname', + 'heading' => 'Lovely user', + 'sortenabled' => 1, + ]); $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:email']); $reportinstance = manager::get_report_from_persistent($report); diff --git a/reportbuilder/tests/external/reports/retrieve_test.php b/reportbuilder/tests/external/reports/retrieve_test.php index 985390063fd..15b1ecd3d45 100644 --- a/reportbuilder/tests/external/reports/retrieve_test.php +++ b/reportbuilder/tests/external/reports/retrieve_test.php @@ -53,8 +53,7 @@ class retrieve_test extends externallib_advanced_testcase { $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder'); $report = $generator->create_report(['name' => 'My report', 'source' => users::class, 'default' => false]); - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname']) - ->set('sortenabled', true)->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname', 'sortenabled' => 1]); $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:email']); // There are three users (admin plus the two previouly created), but we're paging the first two only. diff --git a/reportbuilder/tests/generator/lib.php b/reportbuilder/tests/generator/lib.php index 7720fd3fe65..c31228682fc 100644 --- a/reportbuilder/tests/generator/lib.php +++ b/reportbuilder/tests/generator/lib.php @@ -80,7 +80,15 @@ class core_reportbuilder_generator extends component_generator_base { throw new coding_exception('Record must contain \'uniqueidentifier\' property'); } - return helper::add_report_column($record['reportid'], $record['uniqueidentifier']); + $column = helper::add_report_column($record['reportid'], $record['uniqueidentifier']); + + // Update additional record properties. + unset($record['reportid'], $record['uniqueidentifier']); + if ($properties = column::properties_filter((object) $record)) { + $column->set_many($properties)->update(); + } + + return $column; } /** @@ -100,7 +108,15 @@ class core_reportbuilder_generator extends component_generator_base { throw new coding_exception('Record must contain \'uniqueidentifier\' property'); } - return helper::add_report_filter($record['reportid'], $record['uniqueidentifier']); + $filter = helper::add_report_filter($record['reportid'], $record['uniqueidentifier']); + + // Update additional record properties. + unset($record['reportid'], $record['uniqueidentifier']); + if ($properties = filter::properties_filter((object) $record)) { + $filter->set_many($properties)->update(); + } + + return $filter; } /** @@ -120,7 +136,15 @@ class core_reportbuilder_generator extends component_generator_base { throw new coding_exception('Record must contain \'uniqueidentifier\' property'); } - return helper::add_report_condition($record['reportid'], $record['uniqueidentifier']); + $condition = helper::add_report_condition($record['reportid'], $record['uniqueidentifier']); + + // Update additional record properties. + unset($record['reportid'], $record['uniqueidentifier']); + if ($properties = filter::properties_filter((object) $record)) { + $condition->set_many($properties)->update(); + } + + return $condition; } /** diff --git a/reportbuilder/tests/generator_test.php b/reportbuilder/tests/generator_test.php index 77cf29f918d..f867a6f41b6 100644 --- a/reportbuilder/tests/generator_test.php +++ b/reportbuilder/tests/generator_test.php @@ -64,6 +64,27 @@ class generator_test extends advanced_testcase { $this->assertTrue(column::record_exists($column->get('id'))); } + /** + * Test creating a column, specifying additional properties + */ + public function test_create_column_additional_properties(): void { + $this->resetAfterTest(); + + /** @var core_reportbuilder_generator $generator */ + $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder'); + + $report = $generator->create_report(['name' => 'My report', 'source' => users::class, 'default' => 0]); + $column = $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:lastname', + 'heading' => 'My pants', + 'sortenabled' => 1, + ]); + + $this->assertEquals('My pants', $column->get('heading')); + $this->assertTrue($column->get('sortenabled')); + } + /** * Test creating a filter */ @@ -79,6 +100,25 @@ class generator_test extends advanced_testcase { $this->assertTrue(filter::record_exists($filter->get('id'))); } + /** + * Test creating a filter, specifying additional properties + */ + public function test_create_filter_additional_properties(): void { + $this->resetAfterTest(); + + /** @var core_reportbuilder_generator $generator */ + $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder'); + + $report = $generator->create_report(['name' => 'My report', 'source' => users::class, 'default' => 0]); + $filter = $generator->create_filter([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:lastname', + 'heading' => 'My pants', + ]); + + $this->assertEquals('My pants', $filter->get('heading')); + } + /** * Test creating a condition */ @@ -94,6 +134,25 @@ class generator_test extends advanced_testcase { $this->assertTrue(filter::record_exists($condition->get('id'))); } + /** + * Test creating a condition, specifying additional properties + */ + public function test_create_condition_additional_properties(): void { + $this->resetAfterTest(); + + /** @var core_reportbuilder_generator $generator */ + $generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder'); + + $report = $generator->create_report(['name' => 'My report', 'source' => users::class, 'default' => 0]); + $condition = $generator->create_condition([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:lastname', + 'heading' => 'My pants', + ]); + + $this->assertEquals('My pants', $condition->get('heading')); + } + /** * Test creating an audience */ diff --git a/reportbuilder/tests/local/aggregation/avg_test.php b/reportbuilder/tests/local/aggregation/avg_test.php index aee99bd78e6..661c2129d5a 100644 --- a/reportbuilder/tests/local/aggregation/avg_test.php +++ b/reportbuilder/tests/local/aggregation/avg_test.php @@ -54,14 +54,12 @@ class avg_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', avg::get_class_name()) - ->update(); + $generator->create_column( + ['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => avg::get_class_name()] + ); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ @@ -91,14 +89,12 @@ class avg_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', avg::get_class_name()) - ->update(); + $generator->create_column( + ['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => avg::get_class_name()] + ); // Set callback to format the column (hack column definition to ensure callbacks are executed). $instance = manager::get_report_from_persistent($report); diff --git a/reportbuilder/tests/local/aggregation/count_test.php b/reportbuilder/tests/local/aggregation/count_test.php index f12623ad7df..cbdc62b4c96 100644 --- a/reportbuilder/tests/local/aggregation/count_test.php +++ b/reportbuilder/tests/local/aggregation/count_test.php @@ -54,14 +54,12 @@ class count_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:lastname']) - ->set('aggregation', count::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:lastname', 'aggregation' => count::get_class_name()] + ); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ diff --git a/reportbuilder/tests/local/aggregation/countdistinct_test.php b/reportbuilder/tests/local/aggregation/countdistinct_test.php index bd46883f370..a3103c3cdc3 100644 --- a/reportbuilder/tests/local/aggregation/countdistinct_test.php +++ b/reportbuilder/tests/local/aggregation/countdistinct_test.php @@ -54,14 +54,14 @@ class countdistinct_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:lastname']) - ->set('aggregation', countdistinct::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:lastname', + 'aggregation' => countdistinct::get_class_name(), + ]); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ @@ -90,9 +90,11 @@ class countdistinct_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullname']) - ->set('aggregation', countdistinct::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:fullname', + 'aggregation' => countdistinct::get_class_name(), + ]); $content = $this->get_custom_report_content($report->get('id')); $this->assertCount(1, $content); diff --git a/reportbuilder/tests/local/aggregation/groupconcat_test.php b/reportbuilder/tests/local/aggregation/groupconcat_test.php index c339e626c16..f945eab16e9 100644 --- a/reportbuilder/tests/local/aggregation/groupconcat_test.php +++ b/reportbuilder/tests/local/aggregation/groupconcat_test.php @@ -56,14 +56,14 @@ class groupconcat_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:lastname']) - ->set('aggregation', groupconcat::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:lastname', + 'aggregation' => groupconcat::get_class_name(), + ]); // Assert lastname column was aggregated, and sorted predictably. $content = $this->get_custom_report_content($report->get('id')); @@ -92,9 +92,11 @@ class groupconcat_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullnamewithlink']) - ->set('aggregation', groupconcat::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:fullnamewithlink', + 'aggregation' => groupconcat::get_class_name(), + ]); $content = $this->get_custom_report_content($report->get('id')); $this->assertCount(1, $content); @@ -121,14 +123,14 @@ class groupconcat_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:confirmed']) - ->set('aggregation', groupconcat::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:confirmed', + 'aggregation' => groupconcat::get_class_name(), + ]); // Assert confirmed column was aggregated, and sorted predictably with callback applied. $content = $this->get_custom_report_content($report->get('id')); @@ -170,14 +172,14 @@ class groupconcat_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Badges', 'source' => badges::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'badge:name']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'badge:name', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:description']) - ->set('aggregation', groupconcat::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:description', + 'aggregation' => groupconcat::get_class_name(), + ]); // Assert description column was aggregated, with callbacks accounting for null values. $content = $this->get_custom_report_content($report->get('id')); diff --git a/reportbuilder/tests/local/aggregation/groupconcatdistinct_test.php b/reportbuilder/tests/local/aggregation/groupconcatdistinct_test.php index 8cdb079ccb9..f68459010b0 100644 --- a/reportbuilder/tests/local/aggregation/groupconcatdistinct_test.php +++ b/reportbuilder/tests/local/aggregation/groupconcatdistinct_test.php @@ -66,14 +66,14 @@ class groupconcatdistinct_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:lastname']) - ->set('aggregation', groupconcatdistinct::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:lastname', + 'aggregation' => groupconcatdistinct::get_class_name(), + ]); // Assert lastname column was aggregated, and sorted predictably. $content = $this->get_custom_report_content($report->get('id')); @@ -102,9 +102,11 @@ class groupconcatdistinct_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:fullnamewithlink']) - ->set('aggregation', groupconcatdistinct::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:fullnamewithlink', + 'aggregation' => groupconcatdistinct::get_class_name(), + ]); $content = $this->get_custom_report_content($report->get('id')); $this->assertCount(1, $content); @@ -131,14 +133,14 @@ class groupconcatdistinct_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:confirmed']) - ->set('aggregation', groupconcatdistinct::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), + 'uniqueidentifier' => 'user:confirmed', + 'aggregation' => groupconcatdistinct::get_class_name(), + ]); // Assert confirmed column was aggregated, and sorted predictably with callback applied. $content = $this->get_custom_report_content($report->get('id')); diff --git a/reportbuilder/tests/local/aggregation/max_test.php b/reportbuilder/tests/local/aggregation/max_test.php index 132b186ee00..546900507c8 100644 --- a/reportbuilder/tests/local/aggregation/max_test.php +++ b/reportbuilder/tests/local/aggregation/max_test.php @@ -53,14 +53,12 @@ class max_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', max::get_class_name()) - ->update(); + $generator->create_column( + ['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => max::get_class_name()] + ); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ diff --git a/reportbuilder/tests/local/aggregation/min_test.php b/reportbuilder/tests/local/aggregation/min_test.php index 9a67fa076a6..6f5503846b2 100644 --- a/reportbuilder/tests/local/aggregation/min_test.php +++ b/reportbuilder/tests/local/aggregation/min_test.php @@ -53,14 +53,12 @@ class min_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', min::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => min::get_class_name()] + ); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ diff --git a/reportbuilder/tests/local/aggregation/percent_test.php b/reportbuilder/tests/local/aggregation/percent_test.php index b31cad570ce..cbf84343873 100644 --- a/reportbuilder/tests/local/aggregation/percent_test.php +++ b/reportbuilder/tests/local/aggregation/percent_test.php @@ -53,14 +53,12 @@ class percent_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', percent::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => percent::get_class_name()] + ); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ diff --git a/reportbuilder/tests/local/aggregation/sum_test.php b/reportbuilder/tests/local/aggregation/sum_test.php index 406c05caea8..56b4fb7efd0 100644 --- a/reportbuilder/tests/local/aggregation/sum_test.php +++ b/reportbuilder/tests/local/aggregation/sum_test.php @@ -55,14 +55,12 @@ class sum_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', sum::get_class_name()) - ->update(); + $generator->create_column([ + 'reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => sum::get_class_name() + ]); $content = $this->get_custom_report_content($report->get('id')); $this->assertEquals([ @@ -92,14 +90,12 @@ class sum_test extends core_reportbuilder_testcase { $report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]); // First column, sorted. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname']) - ->set('sortenabled', true) - ->update(); + $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:firstname', 'sortenabled' => 1]); // This is the column we'll aggregate. - $generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended']) - ->set('aggregation', sum::get_class_name()) - ->update(); + $generator->create_column( + ['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:suspended', 'aggregation' => sum::get_class_name()] + ); // Set callback to format the column (hack column definition to ensure callbacks are executed). $instance = manager::get_report_from_persistent($report); diff --git a/reportbuilder/upgrade.txt b/reportbuilder/upgrade.txt index ac572558d56..698eee2331a 100644 --- a/reportbuilder/upgrade.txt +++ b/reportbuilder/upgrade.txt @@ -10,7 +10,7 @@ Information provided here is intended especially for developers. - `data-force-table` to force table view * New optional parameter `pagesize` in external method `core_reportbuilder_reports_get` to set the displayed rows per page. * Javascript reports repository module method `getReport` updated to accept new pagesize parameter. - +* The `create_[column|filter|condition]` test generator methods now allow for setting all persistent properties === 4.1 ===