Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.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.