Index: openacs-4/packages/categories/tcl/test/categories-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/categories/tcl/test/categories-procs.tcl,v diff -u -r1.3.2.2 -r1.3.2.3 --- openacs-4/packages/categories/tcl/test/categories-procs.tcl 9 Oct 2020 14:27:05 -0000 1.3.2.2 +++ openacs-4/packages/categories/tcl/test/categories-procs.tcl 9 Oct 2020 15:59:56 -0000 1.3.2.3 @@ -93,6 +93,100 @@ } } +aa_register_case -procs { + category_tree::add + category::add + category::get + category::get_children + category::get_tree + category::get_data + category::get_id + category::get_id_by_object_title + category::get_name + category::get_names + category::get_parent + } -cats { + api + } category_get_procs { + Test different category::get procs. +} { + aa_run_with_teardown -rollback -test_code { + # + #Create tree + # + set tree_name foo + set tree_id [category_tree::add -name $tree_name] + aa_log "Category tree: $tree_name $tree_id" + # + # Create root category + # + set root_category_id [category::add \ + -tree_id $tree_id \ + -parent_id "" \ + -name $tree_name] + aa_log "Root category: $root_category_id" + # + # Create children categories + # + set children {bar1 "" bar2 "" bar3 ""} + dict for { name id } $children { + set category_id [category::add \ + -tree_id $tree_id \ + -parent_id $root_category_id \ + -description "My category $name" \ + -name $name] + dict set children $name $category_id + aa_log "New children category: $name $category_id" + } + # + # Get + # + dict for { name id } $children { + aa_equals "Check name and description" \ + "[category::get -category_id $id]" \ + "name $name description {My category $name}" + } + # + # Get children + # + aa_equals "Check for children" \ + "[lsort [category::get_children \ + -category_id $root_category_id]]" \ + "[lsort [dict values $children]]" + # + # Get tree + # + dict for { name id } $children { + aa_equals "Check category tree" \ + "[category::get_tree $id]" "$tree_id" + } + # + # Get data + # + dict for { name id } $children { + aa_equals "Check category data" \ + "[category::get_data $id]" "$id $name $tree_id $tree_name" + } + # + # Get id by name/title + # + dict for { name id } $children { + aa_equals "Check category by name" "[category::get_id $name]" "$id" + aa_equals "Check category by object title" \ + "[category::get_id_by_object_title $name]" "$id" + } + # + # Get name by id + # + dict for { name id } $children { + aa_equals "Check category by id" "[category::get_name $id]" "$name" + } + aa_equals "Chec categories by ids" \ + "[lsort [category::get_names [dict values $children]]]" \ + "[lsort [dict keys $children]]" + } +} + # Local variables: # mode: tcl # tcl-indent-level: 4