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 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403]

Tests for the moodle_page class.

Copyright: 2009 Tim Hunt
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 889 lines (34 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

moodle_page_test:: (64 methods):
  setUp()
  test_course_returns_site_before_set()
  test_setting_course_works()
  test_global_course_and_page_course_are_same_with_global_page()
  test_global_course_not_changed_with_non_global_page()
  test_cannot_set_course_once_theme_set()
  test_cannot_set_category_once_theme_set()
  test_cannot_set_category_once_course_set()
  test_categories_array_empty_for_front_page()
  test_set_state_normal_path()
  test_set_state_cannot_skip_one()
  test_header_printed_false_initially()
  test_header_printed_becomes_true()
  test_set_context()
  test_pagetype_defaults_to_script()
  test_set_pagetype()
  test_initialise_default_pagetype()
  test_initialise_default_pagetype_fp()
  test_get_body_classes_empty()
  test_get_body_classes_single()
  test_get_body_classes()
  test_url_to_class_name()
  test_set_docs_path()
  test_docs_path_defaults_from_pagetype()
  test_set_url_root()
  test_set_url_one_param()
  test_set_url_two_params()
  test_set_url_using_moodle_url()
  test_set_url_sets_page_type()
  test_set_url_does_not_change_explicit_page_type()
  test_set_subpage()
  test_set_heading()
  set_title_provider()
  test_set_title()
  test_default_pagelayout()
  test_set_pagelayout()
  test_setting_course_sets_context()
  test_set_category_top_level()
  test_set_nested_categories()
  test_cm_null_initially()
  test_set_cm()
  test_cannot_set_activity_record_before_cm()
  test_setting_cm_sets_context()
  test_activity_record_loaded_if_not_set()
  test_set_activity_record()
  test_cannot_set_inconsistent_activity_record_course()
  test_cannot_set_inconsistent_activity_record_instance()
  test_setting_cm_sets_course()
  test_set_cm_with_course_and_activity_no_db()
  test_cannot_set_cm_with_inconsistent_course()
  test_get_activity_name()
  test_user_is_editing_on()
  test_user_is_editing_off()
  test_default_editing_capabilities()
  test_other_block_editing_cap()
  test_other_editing_cap()
  test_other_editing_caps()
  test_get_renderer()
  test_get_renderer_maintenance()
  test_render_to_cli()
  test_cohort_get_user_theme()
  get_user_theme_provider()
  test_user_can_edit_blocks()
  test_force_lock_all_blocks()

testable_moodle_page:: (3 methods):
  initialise_default_pagetype()
  url_to_class_name()
  all_editing_caps()


Class: moodle_page_test  - X-Ref

Tests for the moodle_page class.

setUp()   X-Ref


test_course_returns_site_before_set()   X-Ref
No description

test_setting_course_works()   X-Ref
No description

test_global_course_and_page_course_are_same_with_global_page()   X-Ref
No description

test_global_course_not_changed_with_non_global_page()   X-Ref
No description

test_cannot_set_course_once_theme_set()   X-Ref
No description

test_cannot_set_category_once_theme_set()   X-Ref
No description

test_cannot_set_category_once_course_set()   X-Ref
No description

test_categories_array_empty_for_front_page()   X-Ref
No description

test_set_state_normal_path()   X-Ref
No description

test_set_state_cannot_skip_one()   X-Ref
No description

test_header_printed_false_initially()   X-Ref
No description

test_header_printed_becomes_true()   X-Ref
No description

test_set_context()   X-Ref
No description

test_pagetype_defaults_to_script()   X-Ref
No description

test_set_pagetype()   X-Ref
No description

test_initialise_default_pagetype()   X-Ref
No description

test_initialise_default_pagetype_fp()   X-Ref
No description

test_get_body_classes_empty()   X-Ref
No description

test_get_body_classes_single()   X-Ref
No description

test_get_body_classes()   X-Ref
No description

test_url_to_class_name()   X-Ref
No description

test_set_docs_path()   X-Ref
No description

test_docs_path_defaults_from_pagetype()   X-Ref
No description

test_set_url_root()   X-Ref
No description

test_set_url_one_param()   X-Ref
No description

test_set_url_two_params()   X-Ref
No description

test_set_url_using_moodle_url()   X-Ref
No description

test_set_url_sets_page_type()   X-Ref
No description

test_set_url_does_not_change_explicit_page_type()   X-Ref
No description

test_set_subpage()   X-Ref
No description

test_set_heading()   X-Ref
No description

set_title_provider()   X-Ref
Data provider for {@see test_set_title}.

return: array

test_set_title(?string $config, bool $appendsitename, string $expected, bool $sitenameset = true)   X-Ref
Test for set_title

param: string|null $config The config value for $CFG->sitenameintitle.
param: bool $appendsitename The $appendsitename parameter
param: string $expected The expected site name to be appended to the title.
param: bool $sitenameset To simulate the absence of the site name being set in the site.
return: void

test_default_pagelayout()   X-Ref
No description

test_set_pagelayout()   X-Ref
No description

test_setting_course_sets_context()   X-Ref
No description

test_set_category_top_level()   X-Ref
No description

test_set_nested_categories()   X-Ref
No description

test_cm_null_initially()   X-Ref
No description

test_set_cm()   X-Ref
No description

test_cannot_set_activity_record_before_cm()   X-Ref
No description

test_setting_cm_sets_context()   X-Ref
No description

test_activity_record_loaded_if_not_set()   X-Ref
No description

test_set_activity_record()   X-Ref
No description

test_cannot_set_inconsistent_activity_record_course()   X-Ref
No description

test_cannot_set_inconsistent_activity_record_instance()   X-Ref
No description

test_setting_cm_sets_course()   X-Ref
No description

test_set_cm_with_course_and_activity_no_db()   X-Ref
No description

test_cannot_set_cm_with_inconsistent_course()   X-Ref
No description

test_get_activity_name()   X-Ref
No description

test_user_is_editing_on()   X-Ref
No description

test_user_is_editing_off()   X-Ref
No description

test_default_editing_capabilities()   X-Ref
No description

test_other_block_editing_cap()   X-Ref
No description

test_other_editing_cap()   X-Ref
No description

test_other_editing_caps()   X-Ref
No description

test_get_renderer()   X-Ref
Test getting a renderer.


test_get_renderer_maintenance()   X-Ref
Tests getting a renderer with a maintenance layout.

This layout has special hacks in place in order to deliver a "maintenance" renderer.

test_render_to_cli()   X-Ref
No description

test_cohort_get_user_theme($usertheme, $sitetheme, $cohortthemes, $expected)   X-Ref
Validate the theme value depending on the user theme and cohorts.


get_user_theme_provider()   X-Ref
Some user cases for validating the expected theme depending on the cohorts, site and user values.

The result is an array of:
'User case description' => [
'usertheme' => '', // User theme.
'sitetheme' => '', // Site theme.
'cohorts' => [],   // Cohort themes.
'expected' => '',  // Expected value returned by cohort_get_user_cohort_theme.
]

return: array

test_user_can_edit_blocks()   X-Ref
Tests user_can_edit_blocks() returns the expected response.


test_force_lock_all_blocks()   X-Ref
Tests that calling force_lock_all_blocks() will cause user_can_edit_blocks() to return false, regardless of capabilities.


Class: testable_moodle_page  - X-Ref

Test-specific subclass to make some protected things public.

initialise_default_pagetype($script = null)   X-Ref
No description

url_to_class_name($url)   X-Ref
No description

all_editing_caps()   X-Ref
No description