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 39 and 310]

Unit tests for the XML-RPC web service.

Copyright: 2015 Jun Pataleta <jun@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 217 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

webservice_xmlrpc_test:: (6 methods):
  setUp()
  test_client_with_array_response()
  test_client_with_value_response()
  test_client_with_fault_response()
  test_encode_request()
  test_decode_response()

webservice_xmlrpc_client_mock:: (4 methods):
  set_mock_response()
  call()
  encode_request()
  decode_response()


Class: webservice_xmlrpc_test  - X-Ref

Unit tests for the XML-RPC web service.

setUp()   X-Ref
Setup.


test_client_with_array_response()   X-Ref
Test for array response.


test_client_with_value_response()   X-Ref
Test for value response.


test_client_with_fault_response()   X-Ref
Test for fault response.


test_encode_request()   X-Ref
Test the XML-RPC request encoding.


test_decode_response()   X-Ref
Test the XML-RPC response decoding


Class: webservice_xmlrpc_client_mock  - X-Ref

Class webservice_xmlrpc_client_mock.

Mock class that returns the processed XML-RPC response.

set_mock_response($mockresponse)   X-Ref
XML-RPC mock response setter.

param: string $mockresponse

call($functionname, $params = array()   X-Ref
Since the call method uses download_file_content and it is hard to make an actual call to a web service,
we'll just have to simulate the receipt of the response from the server using the mock response so we
can test the processing result of this method.

param: string $functionname the function name
param: array $params the parameters of the function
return: mixed The decoded XML RPC response.

encode_request($functionname, $params)   X-Ref
Allows to test the request encoding.

param: string $functionname Name of the method to call.
param: mixed $params Method parameters compatible with the method signature.
return: string

decode_response($response)   X-Ref
Allows to test the response decoding.

param: string $response
return: array