Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

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

PHPUnit tests for quiz_settings class.

Author: Andrew Madden <andrewmadden@catalyst-au.net>
Copyright: 2019 Catalyst IT
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 849 lines (45 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

quizaccess_seb_quiz_settings_testcase:: (31 methods):
  setUp()
  test_config_is_created_from_quiz_settings()
  test_config_is_updated_from_quiz_settings()
  test_config_key_is_created_from_quiz_settings()
  test_config_key_is_updated_from_quiz_settings()
  test_filter_rules_added_to_config()
  test_browser_exam_keys_are_retrieved_as_array()
  test_browser_exam_keys_validation_errors()
  test_config_file_uploaded_converted_to_config()
  test_no_config_file_uploaded()
  get_config_xml()
  test_using_seb_template_override_settings_when_they_set_in_template()
  test_using_seb_template_override_settings_when_not_set_in_template()
  test_using_own_config_settings_are_not_overridden_if_set()
  test_using_own_config_settings_are_not_overridden_if_not_set()
  test_template_has_quit_url_set()
  test_config_file_uploaded_has_quit_url_set()
  test_templateid_set_correctly_when_save_settings()
  save_settings_with_optional_template()
  bad_browser_exam_key_provider()
  filter_rules_provider()
  test_generates_config_values_as_null_when_expected()
  test_quizsettings_cache_exists_after_creation()
  test_quizsettings_cache_purged_after_deletion()
  test_get_quiz_settings_by_quiz_id()
  test_config_cache_exists_after_creation()
  test_config_cache_purged_after_deletion()
  test_get_config_by_quiz_id()
  test_config_key_cache_exists_after_creation()
  test_config_key_cache_purged_after_deletion()
  test_get_config_key_by_quiz_id()


Class: quizaccess_seb_quiz_settings_testcase  - X-Ref

PHPUnit tests for quiz_settings class.

setUp()   X-Ref
Called before every test.


test_config_is_created_from_quiz_settings()   X-Ref
Test that config is generated immediately prior to saving quiz settings.


test_config_is_updated_from_quiz_settings()   X-Ref
Test that config string gets updated from quiz settings.


test_config_key_is_created_from_quiz_settings()   X-Ref
Test that config key is generated immediately prior to saving quiz settings.


test_config_key_is_updated_from_quiz_settings()   X-Ref
Test that config key is generated immediately prior to saving quiz settings.


test_filter_rules_added_to_config(stdClass $settings, string $expectedxml)   X-Ref
Test that different URL filter expressions are turned into config XML.

param: stdClass $settings Quiz settings
param: string $expectedxml SEB Config XML.

test_browser_exam_keys_are_retrieved_as_array()   X-Ref
Test that browser keys are validated and retrieved as an array instead of string.


test_browser_exam_keys_validation_errors($bek, $expectederrorstring)   X-Ref
Test validation of Browser Exam Keys.

param: string $bek Browser Exam Key.
param: string $expectederrorstring Expected error.

test_config_file_uploaded_converted_to_config()   X-Ref
Test that uploaded seb file gets converted to config string.


test_no_config_file_uploaded()   X-Ref
Test test_no_config_file_uploaded


get_config_xml($allowuserquitseb = null, $quitpassword = null)   X-Ref
A helper function to build a config file.

param: mixed $allowuserquitseb Required allowQuit setting.
param: mixed $quitpassword Required hashedQuitPassword setting.
return: string

test_using_seb_template_override_settings_when_they_set_in_template()   X-Ref
Test using USE_SEB_TEMPLATE and have it override settings from the template when they are set.


test_using_seb_template_override_settings_when_not_set_in_template()   X-Ref
Test using USE_SEB_TEMPLATE and have it override settings from the template when they are not set.


test_using_own_config_settings_are_not_overridden_if_set()   X-Ref
Test using USE_SEB_UPLOAD_CONFIG and use settings from the file if they are set.


test_using_own_config_settings_are_not_overridden_if_not_set()   X-Ref
Test using USE_SEB_UPLOAD_CONFIG and use settings from the file if they are not set.


test_template_has_quit_url_set()   X-Ref
Test using USE_SEB_TEMPLATE populates the linkquitseb setting if a quitURL is found.


test_config_file_uploaded_has_quit_url_set()   X-Ref
Test using USE_SEB_UPLOAD_CONFIG populates the linkquitseb setting if a quitURL is found.


test_templateid_set_correctly_when_save_settings()   X-Ref
Test template id set correctly.


save_settings_with_optional_template($quizsettings, $savetype, $templateid = 0)   X-Ref
Helper function in tests to set USE_SEB_TEMPLATE and a template id on the quiz settings.

param: quiz_settings $quizsettings Given quiz settings instance.
param: int $savetype Type of SEB usage.
param: int $templateid Template ID.

bad_browser_exam_key_provider()   X-Ref
Bad browser exam key data provider.

return: array

filter_rules_provider()   X-Ref
Provide settings for different filter rules.

return: array Test data.

test_generates_config_values_as_null_when_expected()   X-Ref
Test that config and config key are null when expected.


test_quizsettings_cache_exists_after_creation()   X-Ref
Test that quizsettings cache exists after creation.


test_quizsettings_cache_purged_after_deletion()   X-Ref
Test that quizsettings cache gets deleted after deletion.


test_get_quiz_settings_by_quiz_id()   X-Ref
Test that we can get quiz_settings by quiz id.


test_config_cache_exists_after_creation()   X-Ref
Test that SEB config cache exists after creation of the quiz.


test_config_cache_purged_after_deletion()   X-Ref
Test that SEB config cache gets deleted after deletion.


test_get_config_by_quiz_id()   X-Ref
Test that we can get SEB config by quiz id.


test_config_key_cache_exists_after_creation()   X-Ref
Test that SEB config key cache exists after creation of the quiz.


test_config_key_cache_purged_after_deletion()   X-Ref
Test that SEB config key cache gets deleted after deletion.


test_get_config_key_by_quiz_id()   X-Ref
Test that we can get SEB config key by quiz id.