Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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.

Class: tour_testcase  - X-Ref

Tests for tour.

setUp()   X-Ref
Setup to store the DB reference.


tearDown()   X-Ref
Tear down to restore the original DB reference.


mock_database()   X-Ref
Helper to mock the database.

return: \PHPUnit\Framework\MockObject\MockObject

dirty_value_provider()   X-Ref
Data provider for the dirty value tester.

return: array

test_dirty_values($name, $value)   X-Ref
Test that setters mark things as dirty.

param: string  $name           The name of the key being tested
param: mixed   $value          The value being set

getter_provider()   X-Ref
Data provider for the get_ tests.

return: array

test_getters($key, $value)   X-Ref
Test that getters return the configured value.

param: string  $key            The name of the key being tested
param: mixed   $value          The value being set

test_persist_non_dirty()   X-Ref
Ensure that non-dirty tours are not persisted.


test_persist_dirty_new()   X-Ref
Ensure that new dirty tours are persisted.


test_persist_force_new()   X-Ref
Ensure that non-dirty, forced tours are persisted.


test_persist_dirty_existing()   X-Ref
Ensure that dirty tours are persisted.


test_persist_force()   X-Ref
Ensure that non-dirty, forced tours are persisted.


test_set_config()   X-Ref
Test setting config.


test_get_config_no_keys()   X-Ref
Test get_config with no keys provided.


get_config_provider()   X-Ref
Data provider for get_config.

return: array

test_get_config_valid_keys($values, $key, $default, $expected)   X-Ref
Test get_config with valid keys provided.

param: object  $values     The config values
param: string  $key        The key
param: mixed   $default    The default value
param: mixed   $expected   The expected value

test_remove_non_persisted()   X-Ref
Check that a tour which has never been persisted is removed correctly.


test_remove_persisted()   X-Ref
Check that a tour which has been persisted is removed correctly.


test_reset_step_sortorder()   X-Ref
Teset that sortorder is reset according to sortorder with values from 0.


test_should_show_for_user_disabled()   X-Ref
Test that a disabled tour should never be shown to users.


should_show_for_user_provider()   X-Ref
Provider for should_show_for_user.

return: array

test_should_show_for_user($completiondate, $requesteddate, $updateddate, $expectation)   X-Ref
Test that a disabled tour should never be shown to users.

param: mixed   $completiondate The user's completion date for this tour
param: mixed   $requesteddate  The user's last requested date for this tour
param: mixed   $updateddate    The date this tour was last updated
param: string  $expectation    The expected tour key

get_tour_key_provider()   X-Ref
Provider for get_tour_key.

return: array

test_get_tour_key($id, $getconfig, $setconfig, $willpersist, $userpref, $expectation)   X-Ref
Test that get_tour_key provides the anticipated unique keys.

param: int     $id             The tour ID
param: array   $getconfig      The mocked values for get_config calls
param: array   $setconfig      The mocked values for set_config calls
param: bool    $willpersist    Whether a persist is expected
param: mixed   $userpref       The value to set for the user preference
param: string  $expectation    The expected tour key

test_requested_user_reset()   X-Ref
Ensure that the request_user_reset function sets an appropriate value for the tour.


test_mark_user_completed()   X-Ref
Ensure that the request_user_reset function sets an appropriate value for the tour.


sortorder_first_last_provider()   X-Ref
Provider for the is_first_tour and is_last_tour tests.

return: array

test_is_first_tour($sortorder, $isfirst, $total, $islast)   X-Ref
Test the is_first_tour() function.

param: int     $sortorder      The new sort order
param: bool    $isfirst        Whether this is the first tour
param: int     $total          The number of tours
param: bool    $islast         Whether this is the last tour

test_is_last_tour_calculated($sortorder, $isfirst, $total, $islast)   X-Ref
Test the is_last_tour() function.

param: int     $sortorder      The new sort order
param: bool    $isfirst        Whether this is the first tour
param: int     $total          The number of tours
param: bool    $islast         Whether this is the last tour

test_is_last_tour_provided($sortorder, $isfirst, $total, $islast)   X-Ref
Test the is_last_tour() function.

param: int     $sortorder      The new sort order
param: bool    $isfirst        Whether this is the first tour
param: int     $total          The number of tours
param: bool    $islast         Whether this is the last tour

get_filter_values_provider()   X-Ref
Data provider for the get_filter_values tests.

return: array

test_get_filter_values($fullconfig, $filtername, $expectedvalues)   X-Ref
Tests for the get_filter_values function.

param: array       $fullconfig     The config value being tested
param: string      $filtername     The name of the filter being tested
param: array       $expectedvalues The expected result

set_filter_values_provider()   X-Ref
Data provider for set_filter_values tests.

return: array

test_set_filter_values_merge($currentvalues, $filtername, $newvalues, $expectedvalues)   X-Ref
Base tests for set_filter_values.

param: array       $currentvalues  The current value
param: string      $filtername     The name of the filter to add to
param: array       $newvalues      The new values to store
param: array       $expectedvalues The combined values