Merge branch 'MDL-84000-401' of https://github.com/paulholden/moodle into MOODLE_401_STABLE

This commit is contained in:
Huong Nguyen 2024-12-18 09:05:40 +07:00
commit 9f9cad60e4
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
27 changed files with 230 additions and 322 deletions

View File

@ -20,14 +20,9 @@ namespace core_admin\reportbuilder\datasource;
use core\task\database_logger;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{boolean_select, date, duration, number, select, text};
use core_reportbuilder\task\send_schedules;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for task logs datasource

View File

@ -20,12 +20,7 @@ namespace core_badges\reportbuilder\datasource;
use core_badges_generator;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for badges datasource

View File

@ -22,13 +22,8 @@ use context_system;
use core_blog_generator;
use core_collator;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{boolean_select, date, select, text};
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for blogs datasource

View File

@ -19,16 +19,11 @@ declare(strict_types=1);
namespace core_cohort\reportbuilder\datasource;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\manager;
use core_reportbuilder\local\filters\user;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for cohorts datasource
*

View File

@ -21,13 +21,8 @@ namespace core_comment\reportbuilder\datasource;
use comment;
use context_course;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{date, text};
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for comments datasource
@ -66,7 +61,7 @@ final class comments_test extends core_reportbuilder_testcase {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Blogs', 'source' => comments::class, 'default' => 1]);
$report = $generator->create_report(['name' => 'Comments', 'source' => comments::class, 'default' => 1]);
$content = $this->get_custom_report_content($report->get('id'));
$this->assertCount(1, $content);
@ -100,7 +95,7 @@ final class comments_test extends core_reportbuilder_testcase {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Blogs', 'source' => comments::class, 'default' => 0]);
$report = $generator->create_report(['name' => 'Comments', 'source' => comments::class, 'default' => 0]);
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'comment:contexturl']);
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'comment:component']);

View File

@ -18,18 +18,9 @@ declare(strict_types=1);
namespace core_course\reportbuilder\datasource;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\local\filters\boolean_select;
use core_reportbuilder\local\filters\date;
use core_reportbuilder\local\filters\select;
use core_reportbuilder\local\filters\tags;
use core_reportbuilder\local\filters\text;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\local\filters\{boolean_select, date, select, tags, text};
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for courses datasources
@ -376,7 +367,7 @@ final class courses_test extends core_reportbuilder_testcase {
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
// Create report containing single column, and given filter.
$report = $generator->create_report(['name' => 'Tasks', 'source' => courses::class, 'default' => 0]);
$report = $generator->create_report(['name' => 'Courses', 'source' => courses::class, 'default' => 0]);
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'course:fullname']);
// Add filter, set it's values.

View File

@ -19,17 +19,14 @@ declare(strict_types=1);
namespace core_course\reportbuilder\datasource;
use completion_completion;
use core_reportbuilder\local\filters\boolean_select;
use core_reportbuilder\local\filters\date;
use core_reportbuilder\local\filters\select;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{boolean_select, date, select};
use core_reportbuilder\tests\core_reportbuilder_testcase;
use grade_item;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
require_once("{$CFG->libdir}/gradelib.php");
/**

View File

@ -22,13 +22,8 @@ use context_course;
use context_user;
use core_collator;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{boolean_select, date, number, select, text};
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for files datasource

View File

@ -19,13 +19,8 @@ declare(strict_types=1);
namespace core_group\reportbuilder\datasource;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{date, text};
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for groups datasource
@ -310,7 +305,7 @@ final class groups_test extends core_reportbuilder_testcase {
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
// Create report containing single column, and given filter.
$report = $generator->create_report(['name' => 'Tasks', 'source' => groups::class, 'default' => 0]);
$report = $generator->create_report(['name' => 'Groups', 'source' => groups::class, 'default' => 0]);
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'group:idnumber']);
// Add filter, set it's values.

View File

@ -21,13 +21,8 @@ namespace core_notes\reportbuilder\datasource;
use core_collator;
use core_notes_generator;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{date, select, text};
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for notes datasource

View File

@ -0,0 +1,187 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
declare(strict_types=1);
namespace core_reportbuilder\tests;
use advanced_testcase;
use core_reportbuilder\manager;
use core_reportbuilder\local\helpers\aggregation;
use core_reportbuilder\local\helpers\report;
use core_reportbuilder\local\helpers\user_filter_manager;
use core_reportbuilder\table\custom_report_table_view;
use Throwable;
/**
* Helper base class for reportbuilder unit tests
*
* @package core_reportbuilder
* @copyright 2021 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class core_reportbuilder_testcase extends advanced_testcase {
/**
* Retrieve content for given report as array of report data
*
* @param int $reportid
* @param int $pagesize
* @param array $filtervalues
* @return array[]
*/
protected function get_custom_report_content(int $reportid, int $pagesize = 30, array $filtervalues = []): array {
$records = [];
// Apply filter values.
user_filter_manager::set($reportid, $filtervalues);
// Create table instance.
$table = custom_report_table_view::create($reportid);
$table->setup();
$table->query_db($pagesize, false);
// Extract raw data.
foreach ($table->rawdata as $record) {
$records[] = $table->format_row($record);
}
$table->close_recordset();
return $records;
}
/**
* 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
*/
protected function datasource_stress_test_columns(string $source): void {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Stress columns', 'source' => $source, 'default' => 0]);
$instance = manager::get_report_from_persistent($report);
// Iterate over each available column, ensure each works correctly independent of any others.
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'));
$this->assertNotEmpty($content);
} catch (Throwable $exception) {
$this->fail("Error for column '{$columnidentifier}': " . $exception->getMessage());
}
report::delete_report_column($report->get('id'), $column->get('id'));
}
}
/**
* Stress test a report source by iterating over all columns and asserting we can create a report while aggregating each
*
* @param string $source
*/
protected function datasource_stress_test_columns_aggregation(string $source): void {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Stress aggregation', 'source' => $source, 'default' => 0]);
$instance = manager::get_report_from_persistent($report);
// Add every column.
$columnidentifiers = array_keys($instance->get_columns());
foreach ($columnidentifiers as $columnidentifier) {
report::add_report_column($report->get('id'), $columnidentifier);
}
// Now iterate over each column, and apply all suitable aggregation types.
foreach ($instance->get_active_columns() as $column) {
$aggregations = aggregation::get_column_aggregations($column->get_type(), $column->get_disabled_aggregation());
foreach (array_keys($aggregations) as $aggregation) {
$column->get_persistent()->set('aggregation', $aggregation)->update();
// We are only asserting the report returns content without errors, not the content itself.
try {
$content = $this->get_custom_report_content($report->get('id'));
$this->assertNotEmpty($content);
} catch (Throwable $exception) {
$this->fail("Error for column '{$column->get_unique_identifier()}' with aggregation '{$aggregation}': " .
$exception->getMessage());
}
}
// Reset the column aggregation.
$column->get_persistent()->set('aggregation', null)->update();
}
}
/**
* Stress test a report source by iterating over all it's conditions and asserting we can create a report using each
*
* @param string $source
* @param string $columnidentifier Should be a simple column, with as few fields and joins as possible, ideally selected
* from the base table itself
*/
protected function datasource_stress_test_conditions(string $source, string $columnidentifier): void {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Stress conditions', 'source' => $source, 'default' => 0]);
$instance = manager::get_report_from_persistent($report);
// Add single column only (to ensure no conditions have reliance on any columns).
report::add_report_column($report->get('id'), $columnidentifier);
// Iterate over each available condition, ensure each works correctly independent of any others.
$conditionidentifiers = array_keys($instance->get_conditions());
foreach ($conditionidentifiers as $conditionidentifier) {
$condition = report::add_report_condition($report->get('id'), $conditionidentifier);
$conditioninstance = $instance->get_condition($condition->get('uniqueidentifier'));
/** @var \core_reportbuilder\local\filters\base $conditionclass */
$conditionclass = $conditioninstance->get_filter_class();
// Set report condition values in order to activate it.
$conditionvalues = $conditionclass::create($conditioninstance)->get_sample_values();
if (empty($conditionvalues)) {
debugging("Missing sample values from filter '{$conditionclass}'", DEBUG_DEVELOPER);
}
$instance->set_condition_values($conditionvalues);
// We are only asserting the report returns content without errors, not the content itself.
try {
$content = $this->get_custom_report_content($report->get('id'));
$this->assertIsArray($content);
} catch (Throwable $exception) {
$this->fail("Error for condition '{$conditionidentifier}': " . $exception->getMessage());
}
report::delete_report_condition($report->get('id'), $condition->get('id'));
}
}
}

View File

@ -16,12 +16,6 @@
declare(strict_types=1);
use core_reportbuilder\manager;
use core_reportbuilder\local\helpers\aggregation;
use core_reportbuilder\local\helpers\report;
use core_reportbuilder\local\helpers\user_filter_manager;
use core_reportbuilder\table\custom_report_table_view;
/**
* Helper base class for reportbuilder unit tests
*
@ -29,155 +23,5 @@ use core_reportbuilder\table\custom_report_table_view;
* @copyright 2021 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class core_reportbuilder_testcase extends advanced_testcase {
/**
* Retrieve content for given report as array of report data
*
* @param int $reportid
* @param int $pagesize
* @param array $filtervalues
* @return array[]
*/
protected function get_custom_report_content(int $reportid, int $pagesize = 30, array $filtervalues = []): array {
$records = [];
// Apply filter values.
user_filter_manager::set($reportid, $filtervalues);
// Create table instance.
$table = custom_report_table_view::create($reportid);
$table->setup();
$table->query_db($pagesize, false);
// Extract raw data.
foreach ($table->rawdata as $record) {
$records[] = $table->format_row($record);
}
$table->close_recordset();
return $records;
}
/**
* 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
*/
protected function datasource_stress_test_columns(string $source): void {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Stress columns', 'source' => $source, 'default' => 0]);
$instance = manager::get_report_from_persistent($report);
// Iterate over each available column, ensure each works correctly independent of any others.
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'));
$this->assertNotEmpty($content);
} catch (Throwable $exception) {
$this->fail("Error for column '{$columnidentifier}': " . $exception->getMessage());
}
report::delete_report_column($report->get('id'), $column->get('id'));
}
}
/**
* Stress test a report source by iterating over all columns and asserting we can create a report while aggregating each
*
* @param string $source
*/
protected function datasource_stress_test_columns_aggregation(string $source): void {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Stress aggregation', 'source' => $source, 'default' => 0]);
$instance = manager::get_report_from_persistent($report);
// Add every column.
$columnidentifiers = array_keys($instance->get_columns());
foreach ($columnidentifiers as $columnidentifier) {
report::add_report_column($report->get('id'), $columnidentifier);
}
// Now iterate over each column, and apply all suitable aggregation types.
foreach ($instance->get_active_columns() as $column) {
$aggregations = aggregation::get_column_aggregations($column->get_type(), $column->get_disabled_aggregation());
foreach (array_keys($aggregations) as $aggregation) {
$column->get_persistent()->set('aggregation', $aggregation)->update();
// We are only asserting the report returns content without errors, not the content itself.
try {
$content = $this->get_custom_report_content($report->get('id'));
$this->assertNotEmpty($content);
} catch (Throwable $exception) {
$this->fail("Error for column '{$column->get_unique_identifier()}' with aggregation '{$aggregation}': " .
$exception->getMessage());
}
}
// Reset the column aggregation.
$column->get_persistent()->set('aggregation', null)->update();
}
}
/**
* Stress test a report source by iterating over all it's conditions and asserting we can create a report using each
*
* @param string $source
* @param string $columnidentifier Should be a simple column, with as few fields and joins as possible, ideally selected
* from the base table itself
*/
protected function datasource_stress_test_conditions(string $source, string $columnidentifier): void {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Stress conditions', 'source' => $source, 'default' => 0]);
$instance = manager::get_report_from_persistent($report);
// Add single column only (to ensure no conditions have reliance on any columns).
report::add_report_column($report->get('id'), $columnidentifier);
// Iterate over each available condition, ensure each works correctly independent of any others.
$conditionidentifiers = array_keys($instance->get_conditions());
foreach ($conditionidentifiers as $conditionidentifier) {
$condition = report::add_report_condition($report->get('id'), $conditionidentifier);
$conditioninstance = $instance->get_condition($condition->get('uniqueidentifier'));
/** @var \core_reportbuilder\local\filters\base $conditionclass */
$conditionclass = $conditioninstance->get_filter_class();
// Set report condition values in order to activate it.
$conditionvalues = $conditionclass::create($conditioninstance)->get_sample_values();
if (empty($conditionvalues)) {
debugging("Missing sample values from filter '{$conditionclass}'", DEBUG_DEVELOPER);
}
$instance->set_condition_values($conditionvalues);
// We are only asserting the report returns content without errors, not the content itself.
try {
$content = $this->get_custom_report_content($report->get('id'));
$this->assertIsArray($content);
} catch (Throwable $exception) {
$this->fail("Error for condition '{$conditionidentifier}': " . $exception->getMessage());
}
report::delete_report_condition($report->get('id'), $condition->get('id'));
}
}
}
class_alias(\core_reportbuilder\tests\core_reportbuilder_testcase::class, \core_reportbuilder_testcase::class);

View File

@ -18,17 +18,12 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\manager;
use core_reportbuilder\local\report\column;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for avg aggregation
*

View File

@ -18,15 +18,10 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for count aggregation
*

View File

@ -18,15 +18,10 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for count distinct aggregation
*

View File

@ -20,15 +20,10 @@ namespace core_reportbuilder\local\aggregation;
use core_badges_generator;
use core_badges\reportbuilder\datasource\badges;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for group concatenation aggregation
*

View File

@ -18,16 +18,11 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\local\report\column;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for group concatenation distinct aggregation
*

View File

@ -18,15 +18,10 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for max aggregation
*

View File

@ -18,15 +18,10 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for min aggregation
*

View File

@ -18,15 +18,10 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for sum aggregation
*

View File

@ -18,17 +18,12 @@ declare(strict_types=1);
namespace core_reportbuilder\local\aggregation;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\manager;
use core_reportbuilder\local\report\column;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for sum aggregation
*

View File

@ -20,7 +20,6 @@ namespace core_reportbuilder\local\helpers;
use core_customfield_generator;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\entities\course;
use core_reportbuilder\local\filters\boolean_select;
use core_reportbuilder\local\filters\date;
@ -28,13 +27,9 @@ use core_reportbuilder\local\filters\select;
use core_reportbuilder\local\filters\text;
use core_reportbuilder\local\report\column;
use core_reportbuilder\local\report\filter;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_course\reportbuilder\datasource\courses;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for custom fields helper
*

View File

@ -19,7 +19,6 @@ declare(strict_types=1);
namespace core_reportbuilder\local\helpers;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\entities\user;
use core_reportbuilder\local\filters\boolean_select;
use core_reportbuilder\local\filters\date;
@ -27,13 +26,9 @@ use core_reportbuilder\local\filters\select;
use core_reportbuilder\local\filters\text;
use core_reportbuilder\local\report\column;
use core_reportbuilder\local\report\filter;
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
/**
* Unit tests for user profile fields helper
*

View File

@ -20,16 +20,11 @@ namespace core_reportbuilder;
use context_system;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
use stdClass;
use core_reportbuilder\local\models\report;
use core_reportbuilder\local\report\base;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\tests\core_reportbuilder_testcase;
use core_user\reportbuilder\datasource\users;
use stdClass;
/**
* Unit tests for the report manager class

View File

@ -1,6 +1,11 @@
This file describes API changes in /reportbuilder/*
Information provided here is intended especially for developers.
=== 4.1.16 ===
* The `core_reportbuilder_testcase` class has been moved to new autoloaded `core_reportbuilder\tests\core_reportbuilder_testcase`
location, affected tests no longer have to manually require `/reportbuilder/tests/helpers.php`
=== 4.1.3 ===
* New database helper method `sql_replace_parameter_names` to help ensure uniqueness of parameters within an expression (where

View File

@ -22,14 +22,8 @@ use context_course;
use context_user;
use core_collator;
use core_reportbuilder_generator;
use core_reportbuilder_testcase;
use core_reportbuilder\local\filters\{boolean_select, date, select};
use core_reportbuilder\local\filters\tags as tags_filter;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\local\filters\{boolean_select, date, select, tags as tags_filter};
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for tags datasource
@ -55,7 +49,7 @@ final class tags_test extends core_reportbuilder_testcase {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Notes', 'source' => tags::class, 'default' => 1]);
$report = $generator->create_report(['name' => 'Tags', 'source' => tags::class, 'default' => 1]);
$content = $this->get_custom_report_content($report->get('id'));
$this->assertCount(2, $content);
@ -90,7 +84,7 @@ final class tags_test extends core_reportbuilder_testcase {
/** @var core_reportbuilder_generator $generator */
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
$report = $generator->create_report(['name' => 'Notes', 'source' => tags::class, 'default' => 0]);
$report = $generator->create_report(['name' => 'Tags', 'source' => tags::class, 'default' => 0]);
// Collection.
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'collection:default']);

View File

@ -19,19 +19,9 @@ declare(strict_types=1);
namespace core_user\reportbuilder\datasource;
use core_collator;
use core_reportbuilder_testcase;
use core_reportbuilder_generator;
use core_reportbuilder\local\filters\boolean_select;
use core_reportbuilder\local\filters\date;
use core_reportbuilder\local\filters\select;
use core_reportbuilder\local\filters\tags;
use core_reportbuilder\local\filters\text;
use core_reportbuilder\local\filters\user as user_filter;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once("{$CFG->dirroot}/reportbuilder/tests/helpers.php");
use core_reportbuilder\local\filters\{boolean_select, date, select, tags, text, user as user_filter};
use core_reportbuilder\tests\core_reportbuilder_testcase;
/**
* Unit tests for users datasource
@ -411,7 +401,7 @@ class users_test extends core_reportbuilder_testcase {
$generator = $this->getDataGenerator()->get_plugin_generator('core_reportbuilder');
// Create report containing single column, and given filter.
$report = $generator->create_report(['name' => 'Tasks', 'source' => users::class, 'default' => 0]);
$report = $generator->create_report(['name' => 'Users', 'source' => users::class, 'default' => 0]);
$generator->create_column(['reportid' => $report->get('id'), 'uniqueidentifier' => 'user:username']);
// Add filter, set it's values.