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.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

Unit tests for the numerical questions answers processor.

Copyright: 2008 The Open University
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 347 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: answerprocessor_test  - X-Ref

Unit test for the numerical questions answers processor.

setUp()   X-Ref
Test setup.


test_parse_response(array $expected, $args)   X-Ref
Test the parse_response function.

param: array $expected
param: mixed $args

parse_response_provider()   X-Ref
Data provider for the parse_response function.

return: array

verify_value_and_unit($exectedval,$expectedunit,$expectedmultiplier,qtype_numerical_answer_processor $ap,$input,$separateunit = null)   X-Ref
Call apply_units and verify the value and units returned.

param: int|float $exectedval
param: null|string $expectedunit
param: int|float $expectedmultiplier
param: qtype_numerical_answer_processor $ap
param: null|int|float $input
param: null|string $separateunit

test_apply_units($expectedvalue,$expectedunit,$expectedmultiplier,$input)   X-Ref
Test the apply_units function with various parameters.

param: mixed $expectedvalue
param: string|null $expectedunit
param: float|int|null $expectedmultiplier
param: string|null $input

apply_units_provider()   X-Ref
Data provider for apply_units tests.

return: array

test_apply_units_with_unit($expectedvalue,$expectedunit,$expectedmultiplier,$input,$units)   X-Ref
Test the apply_units function with various parameters and different units.

param: mixed $expectedvalue
param: string|null $expectedunit
param: float|int|null $expectedmultiplier
param: string|null $input
param: string $units

apply_units_provider_with_units()   X-Ref
Data provider for apply_units with different units.

return: array

test_euro_style(array $expected, string $params)   X-Ref
Test apply_units with a comma float unit.

param: array $expected
param: string $params

euro_provider()   X-Ref
Data provider for apply_units with euro float separators.

return array

test_percent(array $expected, string $params)   X-Ref
Test apply_units with percentage values.

param: array $expected
param: string $params

percent_provider()   X-Ref
Data provider for apply_units with percentages.

return: array

test_currency(array $expected, string $params)   X-Ref
Test apply_units with currency values.

param: array $expected
param: string $params

currency_provider()   X-Ref
Data provider for apply_units with currency values.

return: array