Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

(no description)

File Size: 234 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

get_state_test:: (7 methods):
  setUpBeforeClass()
  test_component_names()
  components_provider()
  test_invalid_agent()
  test_get_state()
  states_provider()
  get_external_class()

extends:: (2 methods):
  validate_component()
  get_state_data()


Class: get_state_test  - X-Ref

Unit tests for xAPI get state webservice.

setUpBeforeClass()   X-Ref
Setup to ensure that fixtures are loaded.


test_component_names(string $component, ?string $expected)   X-Ref
Testing different component names on valid states.

param: string $component component name
param: string|null $expected expected results

components_provider()   X-Ref
Data provider for the test_component_names tests.

return: array

test_invalid_agent()   X-Ref
Testing invalid agent for get_state.


test_get_state(array $info, string $expected)   X-Ref
Testing valid/invalid state.

param: array $info The xAPI state information (to override default values).
param: string $expected Expected results.

states_provider()   X-Ref
Data provider for the test_get_state tests.

return: array

get_external_class()   X-Ref
Return a xAPI external webservice class to operate.

The test needs to fake a component in order to test without
using a real one. This way if in the future any component
implement it's xAPI handler this test will continue working.

return: get_state the external class

Class: extends  - X-Ref

validate_component(string $component)   X-Ref
Method to override validate_component.

param: string $component  The component name in frankenstyle.

get_state_data(string $component, state $data, ?string $expected)   X-Ref
This function do all checks from a standard get_state request.

The reason for this function is because states crafting (special in error
scenarios) is complicated to do via data providers because every test need a specific
testing conditions. For this reason alls tests creates a scenario and then uses this
function to check the results.

param: string $component component name
param: state $data data to encode and send to get_state
param: string $expected expected results (if null an exception is expected)