Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Class: statslib_test  - X-Ref

Test functions that affect daily stats.

setUp()   X-Ref
Setup function
- Allow changes to CFG->debug for testing purposes.


prepare_db($dataset, $tables)   X-Ref
Function to setup database.

param: phpunit_dataset $dataset Containing all the information loaded from fixtures.
param: array $filter Tables to be sent to database.

generate_replacement_list()   X-Ref
Load dataset from XML file.


load_xml_data_file($file)   X-Ref
Load dataset from XML file.

param: string $file The name of the file to load
return: phpunit_dataset

daily_log_provider()   X-Ref
Provides the log data for test_statslib_cron_daily.

return: array of fixture XML log file names.

get_base_weekly_provider()   X-Ref
Set of data for test_statlibs_get_base_weekly

return: array Dates and timezones for which the first day of the week will be calculated

verify_stats($expected, $output = '')   X-Ref
Compare the expected stats to those in the database.

param: array $expected
param: string $output

test_statslib_progress_debug()   X-Ref
Test progress output when debug is on.


test_statslib_progress_no_debug()   X-Ref
Test progress output when debug is off.


test_statslib_get_start_from()   X-Ref
Test the function that gets the start date from the config.


test_statslib_get_base_daily()   X-Ref
Test the function that calculates the start of the day.

NOTE: I don't think this is the way this function should work.
This test documents the current functionality.

test_statslib_get_next_day_start()   X-Ref
Test the function that gets the start of the next day.


test_statslib_get_base_weekly($startwday, $timezone, $timestart, $expected)   X-Ref
Test the function that calculates the start of the week.

param: int $startwday Day in which the week starts (Sunday = 0)
param: string $timezone Default timezone
param: string $timestart Date and time for which the first day of the week will be obtained
param: string $expected Expected date of the first day of the week

test_statslib_get_action_names()   X-Ref
Test the function that gets the action names.

Note: The function results depend on installed modules.  The hard coded lists are the
defaults for a new Moodle 2.3 install.

test_statslib_temp_table_create_and_drop()   X-Ref
Test the temporary table creation and deletion.


test_statslib_temp_table_fill()   X-Ref
Test the temporary table creation and deletion.


test_statslib_temp_table_setup()   X-Ref
Test the temporary table creation and deletion.


test_statslib_temp_table_clean()   X-Ref
Test the function that clean out the temporary tables.


test_statslib_cron_daily($xmlfile)   X-Ref
Test the daily stats function.


test_statslib_cron_daily_no_default_profile_id()   X-Ref
Test the daily stats function.