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: 2417 lines (110 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

cache_test:: (49 methods):
  setUp()
  tearDownAfterClass()
  get_expected_application_cache_store()
  test_cache_config()
  test_windows_nasty_keys()
  test_set_identifiers()
  test_default_application_cache()
  test_default_session_cache()
  test_default_request_cache()
  test_on_cache_without_store()
  run_on_cache()
  test_definition_data_loader()
  test_definition_overridden_loader()
  test_definition_mappings_only()
  test_definition()
  test_definition_simplekeys()
  test_application_ttl_negative()
  test_application_ttl_positive()
  test_session_ttl_positive()
  test_application_manual_locking()
  test_application_event_invalidation()
  test_session_event_invalidation()
  test_application_definition_invalidation()
  test_session_definition_invalidation()
  test_distributed_application_event_invalidation()
  test_application_event_purge()
  test_session_event_purge()
  test_application_definition_purge()
  test_alt_cache_path()
  test_disable_stores()
  test_disable()
  test_multiple_application_loaders()
  test_multiple_session_loaders()
  test_session_cache_switch_user()
  test_session_cache_switch_user_application_mapping()
  test_dual_session_caches()
  test_session_cache_switch_user_multiple()
  test_application_locking()
  test_purge_stores_used_by_definition()
  test_purge_routines()
  test_purge_all_with_adhoc_caches()
  test_defaults_support_searching()
  test_static_acceleration()
  test_identifiers_have_separate_caches()
  test_performance_debug()
  test_static_cache()
  test_performance_debug_off()
  test_session_event_purge_same_second()
  test_session_distinct_storage_key()


Class: cache_test  - X-Ref

PHPunit tests for the cache API

This file is part of Moodle's cache API, affectionately called MUC.
It contains the components that are requried in order to use caching.

setUp()   X-Ref
Set things back to the default before each test.


tearDownAfterClass()   X-Ref
Final task is to reset the cache system


get_expected_application_cache_store()   X-Ref
Returns the expected application cache store.

return: string

test_cache_config()   X-Ref
Tests cache configuration


test_windows_nasty_keys()   X-Ref
Tests for cache keys that would break on windows.


test_set_identifiers()   X-Ref
Tests set_identifiers fails post cache creation.

set_identifiers cannot be called after initial cache instantiation, as you need to create a difference cache.

test_default_application_cache()   X-Ref
Tests the default application cache


test_default_session_cache()   X-Ref
Tests the default session cache


test_default_request_cache()   X-Ref
Tests the default request cache


test_on_cache_without_store()   X-Ref
Tests using a cache system when there are no stores available (who knows what the admin did to achieve this).


run_on_cache(cache_loader $cache)   X-Ref
Runs a standard series of access and use tests on a cache instance.

This function is great because we can use it to ensure all of the loaders perform exactly the same way.

param: cache_loader $cache

test_definition_data_loader()   X-Ref
Tests a definition using a data loader


test_definition_overridden_loader()   X-Ref
Tests a definition using an overridden loader


test_definition_mappings_only()   X-Ref
Test the mappingsonly setting.


test_definition()   X-Ref
Test a very basic definition.


test_definition_simplekeys()   X-Ref
Test a definition using the simple keys.


test_application_ttl_negative()   X-Ref
Test a negative TTL on an application cache.


test_application_ttl_positive()   X-Ref
Test a positive TTL on an application cache.


test_session_ttl_positive()   X-Ref
Test a negative TTL on an session cache.


test_application_manual_locking()   X-Ref
Tests manual locking operations on an application cache


test_application_event_invalidation()   X-Ref
Tests application cache event invalidation


test_session_event_invalidation()   X-Ref
Tests session cache event invalidation


test_application_definition_invalidation()   X-Ref
Tests application cache definition invalidation


test_session_definition_invalidation()   X-Ref
Tests session cache definition invalidation


test_distributed_application_event_invalidation()   X-Ref
Tests application cache event invalidation over a distributed setup.


test_application_event_purge()   X-Ref
Tests application cache event purge


test_session_event_purge()   X-Ref
Tests session cache event purge


test_application_definition_purge()   X-Ref
Tests application cache definition purge


test_alt_cache_path()   X-Ref
Test the use of an alt path.
If we can generate a config instance we are done :)


test_disable_stores()   X-Ref
Test disabling the cache stores.


test_disable()   X-Ref
Test disabling the cache.


test_multiple_application_loaders()   X-Ref
Test that multiple application loaders work ok.


test_multiple_session_loaders()   X-Ref
Test that multiple application loaders work ok.


test_session_cache_switch_user()   X-Ref
Test switching users with session caches.


test_session_cache_switch_user_application_mapping()   X-Ref
Test switching users with session caches.


test_dual_session_caches()   X-Ref
Test two session caches being used at once to confirm collisions don't occur.


test_session_cache_switch_user_multiple()   X-Ref
Test multiple session caches when switching user.


test_application_locking()   X-Ref
Test application locking.


test_purge_stores_used_by_definition()   X-Ref
Test the static cache_helper method purge_stores_used_by_definition.


test_purge_routines()   X-Ref
Test purge routines.


test_purge_all_with_adhoc_caches()   X-Ref
Tests that ad-hoc caches are correctly purged with a purge_all call.


test_defaults_support_searching()   X-Ref
Test that the default stores all support searching.


test_static_acceleration()   X-Ref
Test static acceleration

Note: All the assertGreaterThanOrEqual() in this test should be assertGreaterThan() be because of some microtime()
resolution problems under some OSs / PHP versions, we are accepting equal as valid outcome. For more info see MDL-57147.

test_identifiers_have_separate_caches()   X-Ref
No description

test_performance_debug()   X-Ref
No description

test_static_cache()   X-Ref
No description

test_performance_debug_off()   X-Ref
No description

test_session_event_purge_same_second()   X-Ref
Tests session cache event purge and subsequent visit in the same request.

This test simulates a cache being created, a value being set, then the value being purged.
A subsequent use of the same cache is started in the same request which fills the cache.
A new request is started a short time later.
The cache should be filled.

test_session_distinct_storage_key()   X-Ref
Test that values set in different sessions are stored with different key prefixes.