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 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

(no description)

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

Defines 1 class

taglib_test:: (60 methods):
  setUp()
  test_tag_set_get()
  test_tag_set_add()
  test_tag_set_delete()
  test_add_remove_item_tag()
  test_add_tag_ordering_calculation()
  test_tag_assign()
  test_tag_cleanup()
  test_tag_bulk_delete_instances()
  test_set_item_tags_with_invalid_userid()
  prepare_correlated()
  test_correlations()
  test_cleanup()
  test_guess_tag()
  test_instances()
  test_related_tags()
  test_tag_coll_basic()
  prepare_move_tags()
  test_move_tags_simple()
  test_move_tags_split_tag()
  test_move_tags_merge_tag()
  test_move_tags_with_related()
  test_move_tags_corrupted()
  test_normalize()
  test_create_get()
  test_combine_tags()
  test_combine_tags_with_related()
  test_combine_tags_with_correlated()
  test_get_tags_by_area_in_contexts_empty()
  test_get_tags_by_area_in_contexts_single_tag_one_context()
  test_get_tags_by_area_in_contexts_multiple_tags_one_context()
  test_get_tags_by_area_in_contexts_multiple_tags_multiple_contexts()
  test_get_items_tags_disabled_component()
  test_get_items_tags_empty_itemids()
  test_get_items_tags_unknown_component_itemtype()
  test_get_items_tags_missing_itemids()
  test_set_item_tags_no_multiple_context_add_remove_instances()
  test_set_item_tags_no_multiple_context_updates_context_of_instances()
  test_set_item_tags_no_multiple_contex_deletes_old_instancest()
  test_set_item_tags_allow_multiple_context_doesnt_update_context()
  test_set_item_tags_allow_multiple_context_deletes_instances_in_same_context()
  test_set_item_tags_allow_multiple_context_same_tag_multiple_contexts()
  test_delete_instances_as_record_empty_set()
  test_delete_instances_as_record_missing_set()
  test_delete_instances_as_record_whole_set()
  test_delete_instances_as_record_partial_set()
  test_delete_instances_by_id_empty_set()
  test_delete_instances_by_id_missing_set()
  test_delete_instances_by_id_whole_set()
  test_delete_instances_by_id_partial_set()
  test_delete_instances_with_component()
  test_delete_instances_with_component_and_itemtype()
  test_delete_instances_with_component_and_context()
  test_delete_instances_with_component_and_itemtype_and_context()
  test_change_instances_context_empty_set()
  test_change_instances_context_partial_set()
  test_change_instances_context_multiple_contexts()
  test_change_instances_context_conflicting_instances()
  get_correlated_tags_names()
  add_tag_instance()


Class: taglib_test  - X-Ref

Tag related unit tests.

setUp()   X-Ref
Test set up.

This is executed before running any test in this file.

test_tag_set_get()   X-Ref
Test that the tag_set function throws an exception.
This function was deprecated in 3.1


test_tag_set_add()   X-Ref
Test that tag_set_add function throws an exception.
This function was deprecated in 3.1


test_tag_set_delete()   X-Ref
Test that tag_set_delete function returns an exception.
This function was deprecated in 3.1


test_add_remove_item_tag()   X-Ref
Test the core_tag_tag::add_item_tag() and core_tag_tag::remove_item_tag() functions.


test_add_tag_ordering_calculation()   X-Ref
Test add_item_tag function correctly calculates the ordering for a new tag.


test_tag_assign()   X-Ref
Test that tag_assign function throws an exception.
This function was deprecated in 3.1


test_tag_cleanup()   X-Ref
Test the tag cleanup function used by the cron.


test_tag_bulk_delete_instances()   X-Ref
Test deleting a group of tag instances.


test_set_item_tags_with_invalid_userid()   X-Ref
Test that setting a list of tags for "tag" item type throws exception if userid specified


prepare_correlated()   X-Ref
Prepares environment for testing tag correlations

return: core_tag_tag[] list of used tags

test_correlations()   X-Ref
Test for function compute_correlations() that is part of tag cron


test_cleanup()   X-Ref
Test for function cleanup() that is part of tag cron


test_guess_tag()   X-Ref
No description

test_instances()   X-Ref
No description

test_related_tags()   X-Ref
No description

test_tag_coll_basic()   X-Ref
Very basic test for create/move/update/delete actions, without any itemtype movements.


prepare_move_tags()   X-Ref
Prepares environment for test_move_tags_* tests


test_move_tags_simple()   X-Ref
No description

test_move_tags_split_tag()   X-Ref
No description

test_move_tags_merge_tag()   X-Ref
No description

test_move_tags_with_related()   X-Ref
No description

test_move_tags_corrupted()   X-Ref
No description

test_normalize()   X-Ref
Tests that tag_normalize function throws an exception.
This function was deprecated in 3.1


test_create_get()   X-Ref
Test functions core_tag_tag::create_if_missing() and core_tag_tag::get_by_name_bulk().


test_combine_tags()   X-Ref
Testing function core_tag_tag::combine_tags()


test_combine_tags_with_related()   X-Ref
Testing function core_tag_tag::combine_tags() when related tags are present.


test_combine_tags_with_correlated()   X-Ref
Testing function core_tag_tag::combine_tags() when correlated tags are present.


test_get_tags_by_area_in_contexts_empty()   X-Ref
get_tags_by_area_in_contexts should return an empty array if there
are no tag instances for the area in the given context.


test_get_tags_by_area_in_contexts_single_tag_one_context()   X-Ref
get_tags_by_area_in_contexts should return an array of tags that
have instances in the given context even when there is only a single
instance.


test_get_tags_by_area_in_contexts_multiple_tags_one_context()   X-Ref
get_tags_by_area_in_contexts should return all tags in an array
that have tag instances in for the area in the given context and
should ignore all tags that don't have an instance.


test_get_tags_by_area_in_contexts_multiple_tags_multiple_contexts()   X-Ref
get_tags_by_area_in_contexts should return the unique set of
tags for a area in the given contexts. Multiple tag instances of
the same tag don't result in duplicates in the result set.

Tags with tag instances in the same area with in difference contexts
should be ignored.

test_get_items_tags_disabled_component()   X-Ref
get_items_tags should return an empty array if the tag area is disabled.


test_get_items_tags_empty_itemids()   X-Ref
get_items_tags should return an empty array if the tag item ids list
is empty.


test_get_items_tags_unknown_component_itemtype()   X-Ref
get_items_tags should return an array indexed by the item ids with empty
arrays as the values when the component or itemtype is unknown.


test_get_items_tags_missing_itemids()   X-Ref
get_items_tags should return an array indexed by the item ids with empty
arrays as the values for any item ids that don't have tag instances.

Data setup:
Users: 1, 2, 3
Tags: user 1 = ['foo', 'bar']
user 2 = ['baz', 'bop']
user 3 = []

Expected result:
[
1 => [
1 => 'foo',
2 => 'bar'
],
2 => [
3 => 'baz',
4 => 'bop'
],
3 => []
]

test_set_item_tags_no_multiple_context_add_remove_instances()   X-Ref
set_item_tags should remove any tags that aren't in the given list and should
add any instances that are missing.


test_set_item_tags_no_multiple_context_updates_context_of_instances()   X-Ref
set_item_tags should set all of the tag instance context ids to the given
context if the tag area for the items doesn't allow multiple contexts for
the tag instances.


test_set_item_tags_no_multiple_contex_deletes_old_instancest()   X-Ref
set_item_tags should delete all of the tag instances that don't match
the new set of tags, regardless of the context that the tag instance
is in.


test_set_item_tags_allow_multiple_context_doesnt_update_context()   X-Ref
set_item_tags should not change tag instances in a different context to the one
it's opertating on if the tag area allows instances from multiple contexts.


test_set_item_tags_allow_multiple_context_deletes_instances_in_same_context()   X-Ref
set_item_tags should delete all of the tag instances that don't match
the new set of tags only in the same context if the tag area allows
multiple contexts.


test_set_item_tags_allow_multiple_context_same_tag_multiple_contexts()   X-Ref
set_item_tags should allow multiple instances of the same tag in different
contexts if the tag area allows multiple contexts.


test_delete_instances_as_record_empty_set()   X-Ref
delete_instances_as_record with an empty set of instances should do nothing.


test_delete_instances_as_record_missing_set()   X-Ref
delete_instances_as_record with an instance that doesn't exist should do
nothing.


test_delete_instances_as_record_whole_set()   X-Ref
delete_instances_as_record with a list of all tag instances should
leave no tags left.


test_delete_instances_as_record_partial_set()   X-Ref
delete_instances_as_record with a list of only some tag instances should
delete only the given tag instances and leave other tag instances.


test_delete_instances_by_id_empty_set()   X-Ref
delete_instances_by_id with an empty set of ids should do nothing.


test_delete_instances_by_id_missing_set()   X-Ref
delete_instances_by_id with an id that doesn't exist should do
nothing.


test_delete_instances_by_id_whole_set()   X-Ref
delete_instances_by_id with a list of all tag instance ids should
leave no tags left.


test_delete_instances_by_id_partial_set()   X-Ref
delete_instances_by_id with a list of only some tag instance ids should
delete only the given tag instance ids and leave other tag instances.


test_delete_instances_with_component()   X-Ref
delete_instances should delete all tag instances for a component if given
only the component as a parameter.


test_delete_instances_with_component_and_itemtype()   X-Ref
delete_instances should delete all tag instances for a component if given
only the component as a parameter.


test_delete_instances_with_component_and_context()   X-Ref
delete_instances should delete all tag instances for a component in a context
if given both the component and context id as parameters.


test_delete_instances_with_component_and_itemtype_and_context()   X-Ref
delete_instances should delete all tag instances for a component, item type
and context if given the component, itemtype, and context id as parameters.


test_change_instances_context_empty_set()   X-Ref
change_instances_context should not change any existing instance contexts
if not given any instance ids.


test_change_instances_context_partial_set()   X-Ref
change_instances_context should only change the context of the given ids.


test_change_instances_context_multiple_contexts()   X-Ref
change_instances_context should change multiple items from multiple contexts.


test_change_instances_context_conflicting_instances()   X-Ref
change_instances_context moving an instance from one context into a context
that already has an instance of that tag should throw an exception.


get_correlated_tags_names($tag)   X-Ref
Help method to return sorted array of names of correlated tags to use for assertions

param: core_tag $tag
return: string

add_tag_instance(core_tag_tag $tag, $component, $itemtype, $itemid, $context)   X-Ref
Add a tag instance.

param: core_tag_tag $tag
param: string $component
param: string $itemtype
param: int $itemid
param: context $context
return: stdClass