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]

Tests for step.

Copyright: 2016 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 871 lines (25 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: step_testcase  - X-Ref

Tests for step.

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: moodle_database

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

return: array

test_fetch()   X-Ref
Test the fetch function.


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

param: string  $name       The key to update
param: string  $value      The value to set

step_sortorder_provider()   X-Ref
Provider for is_first_step.

return: array

test_is_first_step($sortorder, $count, $isfirst, $islast)   X-Ref
Test is_first_step.

param: int     $sortorder      The sortorder to check
param: int     $count          Unused in this function
param: bool    $isfirst        Whether this is the first step
param: bool    $islast         Whether this is the last step

test_is_last_step($sortorder, $count, $isfirst, $islast)   X-Ref
Test is_last_step.

param: int     $sortorder      The sortorder to check
param: int     $count          Total number of steps for this test
param: bool    $isfirst        Whether this is the first step
param: bool    $islast         Whether this is the last step

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, $tourconfig, $isforced, $forcedvalue, $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   $tourconfig The tour config
param: bool    $isforced   Whether the setting is forced
param: mixed   $forcedvalue    The example value
param: mixed   $expected   The expected value

set_config_provider()   X-Ref
Data provider for set_config.


test_set_config($initialvalues, $key, $newvalue, $expected)   X-Ref
Test that set_config works in the anticipated fashion.

param: mixed   $initialvalues  The inital value to set
param: string  $key        The key to test
param: mixed   $newvalue   The new value to set
param: mixed   $expected   The expected value

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


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


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


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


test_persist_force_existing()   X-Ref
Ensure that existing non-dirty, forced steps are persisted.


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.


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 key to test
param: mixed   $value      The expected value

get_string_from_input_provider()   X-Ref
Data Provider for get_string_from_input.

return: array

test_get_string_from_input($string, $expected)   X-Ref
Ensure that the get_string_from_input function returns langstring strings correctly.

param: string  $string     The string to test
param: string  $expected   The expected result