Search moodle.org's
Developer Documentation

See Release Notes

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

Differences Between: [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]

(no description)

File Size: 824 lines (33 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 4 classes


Class: base_test  - X-Ref

Course related unit tests

setupBeforeClass()   X-Ref
Setup to ensure that fixtures are loaded.


test_courseformat_saveandload()   X-Ref
Tests the save and load functionality.

author: Jason den Dulk

test_available_hook()   X-Ref
No description

test_supports_news()   X-Ref
Test for supports_news() with a course format plugin that doesn't define 'news_items' in default blocks.


test_supports_news_legacy()   X-Ref
Test for supports_news() for old course format plugins that defines 'news_items' in default blocks.


test_get_view_url()   X-Ref
Test for get_view_url() to ensure that the url is only given for the correct cases


test_get_output_classname($find, $result, $exception)   X-Ref
Test for get_output_classname method.

param: string $find the class to find
param: string $result the expected result classname
param: bool $exception if the method will raise an exception

get_output_classname_provider()   X-Ref
Data provider for test_get_output_classname.

return: array the testing scenarios

test_get_sections_preferences()   X-Ref
Test for the default delete format data behaviour.


test_set_sections_preference()   X-Ref
Test for the default delete format data behaviour.


test_get_last_section_number()   X-Ref
Test that retrieving last section number for a course


test_delete_format_data(bool $usehook)   X-Ref
Test for the default delete format data behaviour.

param: bool $usehook if it should use course_delete to trigger $format->delete_format_data as a hook

delete_format_data_provider()   X-Ref
Data provider for test_delete_format_data.

return: array the testing scenarios

test_duplicate_section()   X-Ref
Test duplicate_section()


test_get_format_string(string $key, ?string $data, ?array $expectedstring)   X-Ref
Test for the default delete format data behaviour.

param: string $key the string key
param: string|null $data any string data
param: array|null $expectedstring the expected string (null for exception)

get_format_string_provider()   X-Ref
Data provider for test_get_format_string.

return: array the testing scenarios

test_move_section_after(string $movesection, string $destination, array $order)   X-Ref
Test for the move_section_after method.

param: string $movesection the reference of the section to move
param: string $destination the reference of the destination section
param: string[] $order the references of the final section order

move_section_after_provider()   X-Ref
Data provider for test_move_section_after.

return: array the testing scenarios

test_get_non_ajax_cm_action_url(string $action, string $expectedparam, bool $exception)   X-Ref
Test for the get_non_ajax_cm_action_url method.

param: string $action the ajax action name
param: string $expectedparam the expected param to check
param: string $exception if an exception is expected

get_non_ajax_cm_action_url_provider()   X-Ref
Data provider for test_get_non_ajax_cm_action_url.

return: array the testing scenarios

Class: format_testformat  - X-Ref

Class format_testformat.

A test class that simulates a course format that doesn't define 'news_items' in default blocks.

get_default_blocks()   X-Ref
Returns the list of blocks to be automatically added for the newly created course.

return: array

Class: format_testformatsections  - X-Ref

Class format_testformatsections.

A test class that simulates a course format with sections.

uses_sections()   X-Ref
Returns if this course format uses sections.

return: true

Class: format_testlegacy  - X-Ref

Class format_testlegacy.

A test class that simulates old course formats that define 'news_items' in default blocks.

get_default_blocks()   X-Ref
Returns the list of blocks to be automatically added for the newly created course.

return: array