Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

Unit tests for core_grades\component_gradeitems;

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

Defines 4 classes

component_gradeitems_test:: (42 methods):
  test_get_itemname_mapping_for_component_does_not_exist()
  test_get_itemname_mapping_for_valid_component_invalid_mapping()
  test_get_itemname_mapping_for_valid_component_valid_mapping()
  is_valid_itemname_provider()
  test_is_valid_itemname()
  test_defines_advancedgrading_itemnames_for_component_does_not_exist()
  test_defines_advancedgrading_itemnames_for_component_no_interfaces()
  test_defines_advancedgrading_itemnames_for_component_grading_no_interface()
  test_defines_advancedgrading_itemnames_for_component_grading_has_interface()
  test_get_advancedgrading_itemnames_for_component_does_not_exist()
  test_get_advancedgrading_itemnames_for_component_no_interfaces()
  test_get_advancedgrading_itemnames_for_component_grading_no_interface()
  test_get_advancedgrading_itemnames_for_component()
  is_advancedgrading_itemname_provider()
  test_is_advancedgrading_itemname()
  get_field_name_for_itemnumber_provider()
  test_get_field_name_for_itemnumber()
  test_get_field_name_for_itemnumber_invalid_itemnumber()
  test_get_field_name_for_itemnumber_component_not_defining_mapping_itemnumber_zero()
  test_get_field_name_for_itemnumber_component_not_defining_mapping_itemnumber_nonzero()
  test_get_field_name_for_itemnumber_component_invalid_mapping_itemnumber_nonzero()
  get_field_name_for_itemname_provider()
  test_get_field_name_for_itemname()
  test_get_field_name_for_itemname_invalid_itemname()
  test_get_field_name_for_itemname_not_defining_mapping_empty_name()
  test_get_field_name_for_itemname_not_defining_mapping_with_name()
  test_get_field_name_for_itemname_invalid_mapping_empty_name()
  test_get_field_name_for_itemname_invalid_mapping_with_name()
  get_itemname_from_itemnumber_provider()
  test_get_itemname_from_itemnumber()
  test_get_itemname_from_itemnumber_outcome_itemnumber()
  test_get_itemname_from_itemnumber_invalid_itemnumber()
  test_get_itemname_from_itemnumber_component_not_defining_mapping_itemnumber_zero()
  test_get_itemname_from_itemnumber_component_not_defining_mapping_itemnumber_nonzero()
  test_get_itemname_from_itemnumber_component_invalid_mapping_itemnumber_nonzero()
  get_itemnumber_from_itemname_provider()
  test_get_itemnumber_from_itemname()
  test_get_itemnumber_from_itemname_invalid_itemname()
  test_get_itemnumber_from_itemname_not_defining_mapping_empty_name()
  test_get_itemnumber_from_itemname_not_defining_mapping_with_name()
  test_get_itemnumber_from_itemname_invalid_mapping_empty_name()
  test_get_itemnumber_from_itemname_invalid_mapping_with_name()

gradeitems:: (5 methods):
  get_itemname_mapping_for_component()
  get_itemname_mapping_for_component()
  get_advancedgrading_itemnames()
  get_itemname_mapping_for_component()
  get_advancedgrading_itemnames()

gradeitems:: (5 methods):
  get_itemname_mapping_for_component()
  get_itemname_mapping_for_component()
  get_advancedgrading_itemnames()
  get_itemname_mapping_for_component()
  get_advancedgrading_itemnames()

gradeitems:: (5 methods):
  get_itemname_mapping_for_component()
  get_itemname_mapping_for_component()
  get_advancedgrading_itemnames()
  get_itemname_mapping_for_component()
  get_advancedgrading_itemnames()


Class: component_gradeitems_test  - X-Ref

Unit tests for core_grades\component_gradeitems;

test_get_itemname_mapping_for_component_does_not_exist()   X-Ref
Ensure that a component which does not implement the mapping class excepts.


test_get_itemname_mapping_for_valid_component_invalid_mapping()   X-Ref
Ensure that a component which does not implement the mapping class correctly excepts.


test_get_itemname_mapping_for_valid_component_valid_mapping()   X-Ref
Ensure that a component which implements the mapping class correctly eets the correct set of mappings.


is_valid_itemname_provider()   X-Ref
Data provider for is_valid_itemname tests.

return: array

test_is_valid_itemname(string $itemname, bool $isadvanced)   X-Ref
Ensure that a component implementing advanced grading returns the correct areas.

param: string $itemname
param: bool $isadvanced

test_defines_advancedgrading_itemnames_for_component_does_not_exist()   X-Ref
Ensure that a component which does not implement the advancedgrading interface returns this.


test_defines_advancedgrading_itemnames_for_component_no_interfaces()   X-Ref
Ensure that a component which does not implement the advancedgrading interface returns this.


test_defines_advancedgrading_itemnames_for_component_grading_no_interface()   X-Ref
Ensure that a component which implements the item mapping but not implement the advancedgrading interface returns this.


test_defines_advancedgrading_itemnames_for_component_grading_has_interface()   X-Ref
Ensure that a component which implements the item mapping but not implement the advancedgrading interface returns this.


test_get_advancedgrading_itemnames_for_component_does_not_exist()   X-Ref
Ensure that a component which does not implement the advancedgrading interface returns this.


test_get_advancedgrading_itemnames_for_component_no_interfaces()   X-Ref
Ensure that a component which does not implement the advancedgrading interface returns this.


test_get_advancedgrading_itemnames_for_component_grading_no_interface()   X-Ref
Ensure that a component which implements the item mapping but not implement the advancedgrading interface returns this.


test_get_advancedgrading_itemnames_for_component()   X-Ref
Ensure that a component implementing advanced grading returns the correct areas.


is_advancedgrading_itemname_provider()   X-Ref
Data provider for is_advancedgrading_itemname tests.

return: array

test_is_advancedgrading_itemname(string $itemname, bool $isadvanced)   X-Ref
Ensure that a component implementing advanced grading returns the correct areas.

param: string $itemname
param: bool $isadvanced

get_field_name_for_itemnumber_provider()   X-Ref
Data provider for get_field_name_for_itemnumber.

return: array

test_get_field_name_for_itemnumber(int $itemnumber, string $fieldname, string $expected)   X-Ref
Ensure that valid field names are correctly mapped for a valid component.

param: int $itemnumber The item itemnumber to test
param: string $fieldname The field name being translated
param: string $expected The expected value

test_get_field_name_for_itemnumber_invalid_itemnumber()   X-Ref
Ensure that an invalid itemnumber does not provide any field name.


test_get_field_name_for_itemnumber_component_not_defining_mapping_itemnumber_zero()   X-Ref
Ensure that a component which does not define a mapping can still get a mapping for itemnumber 0.


test_get_field_name_for_itemnumber_component_not_defining_mapping_itemnumber_nonzero()   X-Ref
Ensure that a component which does not define a mapping cannot get a mapping for itemnumber 1+.


test_get_field_name_for_itemnumber_component_invalid_mapping_itemnumber_nonzero()   X-Ref
Ensure that a component which incorrectly defines a mapping cannot get a mapping for itemnumber 1+.


get_field_name_for_itemname_provider()   X-Ref
Data provider for get_field_name_for_itemname.

return: array

test_get_field_name_for_itemname(string $itemname, string $fieldname, string $expected)   X-Ref
Ensure that valid field names are correctly mapped for a valid component.

param: string $itemname The item itemname to test
param: string $fieldname The field name being translated
param: string $expected The expected value

test_get_field_name_for_itemname_invalid_itemname()   X-Ref
Ensure that an invalid itemname does not provide any field name.


test_get_field_name_for_itemname_not_defining_mapping_empty_name()   X-Ref
Ensure that an empty itemname provides a matching fieldname regardless of whether the component exists or
not.


test_get_field_name_for_itemname_not_defining_mapping_with_name()   X-Ref
Ensure that an valid component with some itemname excepts.


test_get_field_name_for_itemname_invalid_mapping_empty_name()   X-Ref
Ensure that an empty itemname provides a matching fieldname even if the mapping is invalid.


test_get_field_name_for_itemname_invalid_mapping_with_name()   X-Ref
Ensure that an invalid mapping with some itemname excepts.


get_itemname_from_itemnumber_provider()   X-Ref
Data provider for get_itemname_from_itemnumber.

return: array

test_get_itemname_from_itemnumber(int $itemnumber, string $expected)   X-Ref
Ensure that item names are correctly mapped for a valid component.

param: int $itemnumber The item itemnumber to test
param: string $expected The expected value

test_get_itemname_from_itemnumber_outcome_itemnumber()   X-Ref
Ensure that an itemnumber over 1000 is treated as itemnumber 0 for the purpose of outcomes.


test_get_itemname_from_itemnumber_invalid_itemnumber()   X-Ref
Ensure that an invalid itemnumber does not provide any field name.


test_get_itemname_from_itemnumber_component_not_defining_mapping_itemnumber_zero()   X-Ref
Ensure that a component which does not define a mapping can still get a mapping for itemnumber 0.


test_get_itemname_from_itemnumber_component_not_defining_mapping_itemnumber_nonzero()   X-Ref
Ensure that a component which does not define a mapping cannot get a mapping for itemnumber 1+.


test_get_itemname_from_itemnumber_component_invalid_mapping_itemnumber_nonzero()   X-Ref
Ensure that a component which incorrectly defines a mapping cannot get a mapping for itemnumber 1+.


get_itemnumber_from_itemname_provider()   X-Ref
Data provider for get_itemname_from_itemnumber.

return: array

test_get_itemnumber_from_itemname(string $itemname, int $expected)   X-Ref
Ensure that valid item names are correctly mapped for a valid component.

param: string $itemname The item itemname to test
param: int $expected The expected value

test_get_itemnumber_from_itemname_invalid_itemname()   X-Ref
Ensure that an invalid itemname excepts.


test_get_itemnumber_from_itemname_not_defining_mapping_empty_name()   X-Ref
Ensure that an empty itemname provides a correct itemnumber regardless of whether the component exists or
not.


test_get_itemnumber_from_itemname_not_defining_mapping_with_name()   X-Ref
Ensure that an valid component with some itemname excepts.


test_get_itemnumber_from_itemname_invalid_mapping_empty_name()   X-Ref
Ensure that an empty itemname provides a matching fieldname even if the mapping is invalid.


test_get_itemnumber_from_itemname_invalid_mapping_with_name()   X-Ref
Ensure that an invalid mapping with some itemname excepts.


Class: gradeitems  - X-Ref

Valid class for testing mappings.

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_advancedgrading_itemnames()   X-Ref
Get the list of items which define advanced grading.

return: array

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_advancedgrading_itemnames()   X-Ref
Get the list of items which define advanced grading.

return: array

Class: gradeitems  - X-Ref

Valid class for testing mappings.

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_advancedgrading_itemnames()   X-Ref
Get the list of items which define advanced grading.

return: array

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_advancedgrading_itemnames()   X-Ref
Get the list of items which define advanced grading.

return: array

Class: gradeitems  - X-Ref

Invalid class for testing mappings.

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_advancedgrading_itemnames()   X-Ref
Get the list of items which define advanced grading.

return: array

get_itemname_mapping_for_component()   X-Ref
Get the grade item mapping of item number to item name.

return: array

get_advancedgrading_itemnames()   X-Ref
Get the list of items which define advanced grading.

return: array