Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Class: logging_test  - X-Ref

This file contains the unit tests for the task logging system.

tearDown()   X-Ref
Relevant tearDown for logging tests.


test_logmode_none()   X-Ref
When the logmode is set to none, logging should not start.


test_start_logmode_all()   X-Ref
When the logmode is set to all that log capture is started.


test_start_logmode_fail()   X-Ref
When the logmode is set to fail that log capture is started.


test_logmode_fail_with_passing_adhoc_task()   X-Ref
When the logmode is set to fail, passing adhoc tests should not be logged.


test_logmode_fail_with_passing_scheduled_task()   X-Ref
When the logmode is set to fail, passing scheduled tests should not be logged.


test_logmode_fail_with_failing_adhoc_task()   X-Ref
When the logmode is set to fail, failing adhoc tests should be logged.


test_logmode_fail_with_failing_scheduled_task()   X-Ref
When the logmode is set to fail, failing scheduled tests should be logged.


test_logmode_any_with_failing_adhoc_task()   X-Ref
When the logmode is set to fail, failing adhoc tests should be logged.


test_logmode_any_with_failing_scheduled_task()   X-Ref
When the logmode is set to fail, failing scheduled tests should be logged.


test_logmode_any_with_passing_adhoc_task()   X-Ref
When the logmode is set to fail, passing adhoc tests should be logged.


test_logmode_any_with_passing_scheduled_task()   X-Ref
When the logmode is set to fail, passing scheduled tests should be logged.


test_prevent_nested_logging()   X-Ref
Ensure that start_logging cannot be called in a nested fashion.


test_repeated_usages()   X-Ref
Ensure that logging can be called after a previous log has finished.


test_finalise_log_no_logging()   X-Ref
Enusre that when finalise_log is called when logging is not active, nothing happens.


test_flush_on_own_buffer()   X-Ref
When log capture is enabled, calls to the flush function should cause log output to be both returned and captured.


test_flush_does_not_flush_inner_buffers()   X-Ref
When log capture is enabled, calls to the flush function should not affect any subsequent ob_start.


test_inner_flushed_buffers_are_logged()   X-Ref
When log capture is enabled, calls to the flush function should not affect any subsequent ob_start.


get_test_adhoc_task()   X-Ref
Get an example adhoc task to use for testing.

return: adhoc_task

get_test_scheduled_task()   X-Ref
Get an example scheduled task to use for testing.

return: scheduled_task

get_mocked_logger()   X-Ref
Create and configure a mocked task logger.

return: logging_test_mocked_logger

mock_database()   X-Ref
Mock the database.


Class: logging_test_mocked_logger  - X-Ref

Mocked logger.

test_reset()   X-Ref
Reset the test class.


is_configured()   X-Ref
Whether the task is configured and ready to log.

return: bool

store_log_for_task(task_base $task, string $logpath, bool $failed,int $dbreads, int $dbwrites, float $timestart, float $timeend)   X-Ref
Store the log for the specified task.

param: task_base   $task The task that the log belongs to.
param: string      $logpath The path to the log on disk
param: bool        $failed Whether the task failed
param: int         $dbreads The number of DB reads
param: int         $dbwrites The number of DB writes
param: float       $timestart The start time of the task
param: float       $timeend The end time of the task

has_log_report()   X-Ref
Whether this task logger has a report available.

return: bool

get_url_for_task_class(string $classname)   X-Ref
Get any URL available for viewing relevant task log reports.

param: string      $classname The task class to fetch for
return: \moodle_url