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.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

File Size: 1253 lines (54 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 1 file
 mod/quiz/accessrule/seb/tests/test_helper_trait.php

Defines 1 class

rule_test:: (51 methods):
  setUp()
  get_seb_download_link()
  get_seb_launch_link()
  get_seb_config_download_link()
  valid_form_data_provider()
  invalid_form_data_provider()
  test_validate_settings_with_valid_data()
  test_validate_settings_with_invalid_data()
  test_settings_validation_is_not_run_if_settings_are_locked()
  test_settings_validation_is_not_run_if_conflicting_permissions()
  test_validate_settings_is_not_run_if_a_user_do_not_have_permissions_to_manage_seb_settings()
  test_create_settings_with_existing_quiz()
  test_settings_are_not_saved_if_settings_are_locked()
  test_settings_are_not_saved_if_conflicting_permissions()
  test_save_settings_throw_an_exception_if_cm_not_found()
  test_delete_settings_without_existing_settings()
  test_delete_settings_with_existing_settings()
  check_invalid_config_key()
  test_access_prevented_if_config_key_invalid()
  test_access_prevented_if_config_key_invalid_uploaded_config()
  test_access_prevented_if_config_key_invalid_uploaded_template()
  test_access_allowed_if_config_key_valid()
  test_access_allowed_if_config_key_valid_uploaded_config()
  test_access_allowed_if_config_key_valid_template()
  test_access_allowed_if_browser_exam_keys_valid()
  test_access_allowed_if_browser_exam_keys_valid_use_uploaded_file()
  check_invalid_browser_exam_key()
  test_access_prevented_if_browser_exam_keys_are_invalid()
  test_access_prevented_if_browser_exam_keys_are_invalid_use_uploaded_file()
  test_access_prevented_if_browser_exam_keys_are_invalid_use_template()
  test_access_allowed_if_using_client_config_basic_header_is_valid()
  test_access_prevented_if_using_client_configuration_and_basic_head_is_invalid()
  test_access_allowed_if_using_client_configuration_and_basic_head_is_invalid_use_uploaded_config()
  test_access_allowed_if_using_client_configuration_and_basic_head_is_invalid_use_template()
  test_access_allowed_if_seb_not_required()
  test_access_allowed_if_user_has_bypass_capability()
  test_mod_quiz_form_cannot_be_saved_using_template_and_template_is_not_set()
  test_mod_quiz_form_cannot_be_saved_using_uploaded_file_and_file_is_not_valid()
  test_mod_quiz_form_cannot_be_saved_if_global_settings_force_quiz_password_and_none_is_set()
  test_mod_quiz_form_can_be_saved_if_global_settings_force_quiz_password_and_is_set()
  test_mod_quiz_form_can_be_saved_if_global_settings_force_quiz_password_and_none_no_seb()
  test_get_download_seb_button()
  test_get_get_action_buttons_shows_download_seb_link()
  test_get_get_action_buttons_shows_launch_and_download_config_links()
  test_get_get_action_buttons_shows_launch_and_download_config_links_as_configured()
  test_get_quit_button()
  test_description()
  test_description_shows_download_config_link_when_required()
  test_blocks_display_before_attempt_started()
  test_blocks_display_after_attempt_finished()
  test_should_redirect_to_seb_config_link()


Class: rule_test  - X-Ref

PHPUnit tests for plugin rule class.

setUp()   X-Ref
Called before every test.


get_seb_download_link()   X-Ref
Helper method to get SEB download link for testing.

return: string

get_seb_launch_link()   X-Ref
Helper method to get SEB launch link for testing.

return: string

get_seb_config_download_link()   X-Ref
Helper method to get SEB config download link for testing.

return: string

valid_form_data_provider()   X-Ref
Provider to return valid form field data when saving settings.

return: array

invalid_form_data_provider()   X-Ref
Provider to return invalid form field data when saving settings.

return: array

test_validate_settings_with_valid_data(string $setting, string $data)   X-Ref
Test no errors are found with valid data.

param: string $setting
param: string $data

test_validate_settings_with_invalid_data(string $setting, string $data)   X-Ref
Test errors are found with invalid data.

param: string $setting
param: string $data

test_settings_validation_is_not_run_if_settings_are_locked()   X-Ref
Test settings validation is not run if settings are locked.


test_settings_validation_is_not_run_if_conflicting_permissions()   X-Ref
Test settings validation is not run if settings are conflicting.


test_validate_settings_is_not_run_if_a_user_do_not_have_permissions_to_manage_seb_settings()   X-Ref
Test bypassing validation if user don't have permissions to manage seb settings.


test_create_settings_with_existing_quiz()   X-Ref
Test settings are saved to DB.


test_settings_are_not_saved_if_settings_are_locked()   X-Ref
Test settings are not saved to DB if settings are locked.


test_settings_are_not_saved_if_conflicting_permissions()   X-Ref
Test settings are not saved to DB if conflicting permissions.


test_save_settings_throw_an_exception_if_cm_not_found()   X-Ref
Test exception thrown if cm could not be found while saving settings.


test_delete_settings_without_existing_settings()   X-Ref
Test nothing happens when deleted is called without settings saved.


test_delete_settings_with_existing_settings()   X-Ref
Test settings are deleted from DB.


check_invalid_config_key()   X-Ref
A helper method to check invalid config key.


test_access_prevented_if_config_key_invalid()   X-Ref
Test access prevented if config key is invalid.


test_access_prevented_if_config_key_invalid_uploaded_config()   X-Ref
Test access prevented if config keys is invalid and using uploaded config.


test_access_prevented_if_config_key_invalid_uploaded_template()   X-Ref
Test access prevented if config keys is invalid and using template.


test_access_allowed_if_config_key_valid()   X-Ref
Test access not prevented if config key matches header.


test_access_allowed_if_config_key_valid_uploaded_config()   X-Ref
Test access not prevented if config key matches header.


test_access_allowed_if_config_key_valid_template()   X-Ref
Test access not prevented if config key matches header.


test_access_allowed_if_browser_exam_keys_valid()   X-Ref
Test access not prevented if browser exam keys match headers.


test_access_allowed_if_browser_exam_keys_valid_use_uploaded_file()   X-Ref
Test access not prevented if browser exam keys match headers.


check_invalid_browser_exam_key($downloadseblink = true, $launchlink = true, $downloadconfiglink = true)   X-Ref
A helper method to check invalid browser key.

param: bool $downloadseblink Make sure download SEB link is present.
param: bool $launchlink Make sure launch SEB link is present.
param: bool $downloadconfiglink Make download config link is present.

test_access_prevented_if_browser_exam_keys_are_invalid()   X-Ref
Test access prevented if browser exam keys do not match headers.


test_access_prevented_if_browser_exam_keys_are_invalid_use_uploaded_file()   X-Ref
Test access prevented if browser exam keys do not match headers and using uploaded config.


test_access_prevented_if_browser_exam_keys_are_invalid_use_template()   X-Ref
Test access not prevented if browser exam keys do not match headers and using template.


test_access_allowed_if_using_client_config_basic_header_is_valid()   X-Ref
Test access allowed if using client configuration and SEB user agent header is valid.


test_access_prevented_if_using_client_configuration_and_basic_head_is_invalid()   X-Ref
Test access prevented if using client configuration and SEB user agent header is invalid.


test_access_allowed_if_using_client_configuration_and_basic_head_is_invalid_use_uploaded_config()   X-Ref
Test access allowed if using client configuration and SEB user agent header is invalid and use uploaded file.


test_access_allowed_if_using_client_configuration_and_basic_head_is_invalid_use_template()   X-Ref
Test access allowed if using client configuration and SEB user agent header is invalid and use template.


test_access_allowed_if_seb_not_required()   X-Ref
Test access not prevented if SEB not required.


test_access_allowed_if_user_has_bypass_capability()   X-Ref
Test access not prevented if USER has bypass capability.


test_mod_quiz_form_cannot_be_saved_using_template_and_template_is_not_set()   X-Ref
Test that quiz form cannot be saved if using template, but not actually pick one.


test_mod_quiz_form_cannot_be_saved_using_uploaded_file_and_file_is_not_valid()   X-Ref
Test that quiz form cannot be saved if uploaded invalid file.


test_mod_quiz_form_cannot_be_saved_if_global_settings_force_quiz_password_and_none_is_set()   X-Ref
Test that quiz form cannot be saved if the global settings are set to require a password and no password is set.


test_mod_quiz_form_can_be_saved_if_global_settings_force_quiz_password_and_is_set()   X-Ref
Test that access to quiz is allowed if global setting is set to restrict quiz if no quiz password is set, and global quiz
password is set.


test_mod_quiz_form_can_be_saved_if_global_settings_force_quiz_password_and_none_no_seb()   X-Ref
Test that quiz form can be saved if the global settings are set to require a password and no seb usage selected.


test_get_download_seb_button()   X-Ref
Test get_download_seb_button, checks for empty config setting quizaccess_seb/downloadlink.


test_get_get_action_buttons_shows_download_seb_link()   X-Ref
Test get_download_seb_button shows download SEB link when required,


test_get_get_action_buttons_shows_launch_and_download_config_links()   X-Ref
Test get_download_seb_button shows SEB config related links when required.


test_get_get_action_buttons_shows_launch_and_download_config_links_as_configured()   X-Ref
Test get_download_seb_button shows SEB config related links as configured in "showseblinks".


test_get_quit_button()   X-Ref
Test get_quit_button. If attempt count is greater than 0


test_description()   X-Ref
Test description, checks for a valid SEB session and attempt count .


test_description_shows_download_config_link_when_required()   X-Ref
Test description displays download SEB config button when required.


test_blocks_display_before_attempt_started()   X-Ref
Test block display before a quiz started.


test_blocks_display_after_attempt_finished()   X-Ref
Test block display after a quiz completed.


test_should_redirect_to_seb_config_link()   X-Ref
Test we can decide if need to redirect to SEB config link.