_categories__category_object_mapping (private)

 _categories__category_object_mapping

Defined in packages/categories/tcl/test/categories-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_run_with_teardown aa_run_with_teardown (public) aa_section aa_section (public) _categories__category_object_mapping _categories__category_object_mapping _categories__category_object_mapping->aa_equals _categories__category_object_mapping->aa_log _categories__category_object_mapping->aa_log_result _categories__category_object_mapping->aa_run_with_teardown _categories__category_object_mapping->aa_section

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{
    aa_run_with_teardown -rollback -test_code {

        #
        # We need a content item to test category::get_objects later
        #
        set folder_id [content::folder::new  -label "One folder"  -name __category_object_mapping_folder]
        content::folder::register_content_type  -folder_id $folder_id  -content_type "content_revision"
        set one_object_id [content::item::new  -name __category_object_mapping  -parent_id $folder_id  -title "One Item"  -content_type content_revision  -text {some text}]

        aa_equals "Object context for the object is as expected"  [list "/o/$one_object_id" [acs_object_name $one_object_id]]  [category::get_object_context $one_object_id]

        aa_section "Create tree"
        set tree_name foo
        set tree_description "Just a dummy category tree"
        set tree_site_wide_p f
        set tree_id [category_tree::add  -description $tree_description  -site_wide_p  $tree_site_wide_p  -name $tree_name]
        aa_log "Category tree: $tree_name $tree_id"
        aa_section "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"
        }

        aa_section "Map categories"

        aa_equals "category_tree::get_trees returns expected"  [category_tree::get_trees $one_object_id]  ""

        set categories [list  $root_category_id  {*}[dict values $children]]
        category::map_object  -object_id $one_object_id  $categories

        aa_section "Check mappings"

        set mapped_categories [category::get_mapped_categories $one_object_id]
        aa_equals "Api retrieves the expected mapped categories"  [lsort $categories] [lsort $mapped_categories]

        set mapped_categories [category::get_mapped_categories -tree_id $one_object_id $one_object_id]
        aa_equals "Api retrieves 0 categories if the tree is wrong"  [llength $mapped_categories] 0

        set mapped_categories [category::get_mapped_categories -tree_id $tree_id $one_object_id]
        aa_equals "Api retrieves the expected mapped categories also by tree"  [lsort $categories] [lsort $mapped_categories]

        category::get_mapped_categories_multirow -multirow __test_category_map $one_object_id
        aa_true "The multirow was created"  [template::multirow exists __test_category_map]
        aa_equals "The multirow has the same size as the mapped categories"  [template::multirow size __test_category_map] [llength $mapped_categories]
        template::multirow sort __test_category_map category_id
        set i 0
        template::multirow foreach __test_category_map {
            aa_equals "Category in the multirow corresponds to that from the list"  $category_id [lindex $mapped_categories $i]
            incr i
        }

        aa_equals "category_tree::get_trees returns expected"  [category_tree::get_trees $one_object_id]  [list $tree_id]

        set cloud_tags [category::tagcloud::get_tags -tree_id $tree_id]
        aa_equals "category::tagcloud::get_tags returns expected"  [lsort -index 0 $cloud_tags]  [list  [list $root_category_id 1 $tree_name]  [list [lindex $categories 1] 1 "bar1"]  [list [lindex $categories 2] 1 "bar2"]  [list [lindex $categories 3] 1 "bar3"]  ]

        set tag_cloud [category::tagcloud::tagcloud -tree_id $tree_id]
        set rgxp <.*
        foreach tag $cloud_tags {
            append rgxp [join $tag .*].*
        }
        append rgxp >
        aa_true "Tagcloud looks like '$rgxp'" [regexp $rgxp $tag_cloud]

        foreach category_id $categories {
            set object_ids [category::get_objects -category_id $category_id]
            aa_equals "Getting the object from one of the mapped categories '$category_id' returns our object"  $object_ids $one_object_id
            set object_ids [category::get_objects -category_id $category_id -content_type content_revision]
            aa_equals "Getting the content_revision objects from one of the mapped categories '$category_id' returns our object"  $object_ids $one_object_id
            set object_ids [category::get_objects -category_id $category_id -object_type content_item]
            aa_equals "Getting the content_item objects from one of the mapped categories '$category_id' returns our object"  $object_ids $one_object_id

            set object_ids [category::get_objects -category_id $category_id -content_type text/plain]
            aa_equals "Getting the text/plain objects from one of the mapped categories '$category_id' returns nothing"  [llength $object_ids] 0
            set object_ids [category::get_objects -category_id $category_id -object_type user]
            aa_equals "Getting the user objects from one of the mapped categories '$category_id' returns nothing"  [llength $object_ids] 0
        }


        aa_section "Unmap categories"
        category::map_object  -remove_old  -object_id $one_object_id  {}

        aa_equals "Mappings were deleted"  [llength [category::get_mapped_categories $one_object_id]] 0
        aa_equals "Mappings were deleted also by tree"  [llength [category::get_mapped_categories -tree_id $tree_id $one_object_id]] 0
        category::get_mapped_categories_multirow -multirow __test_category_map $one_object_id
        aa_equals "The multirow has size 0"  [template::multirow size __test_category_map] 0
    }
}} {
          aa_log "Running testcase body $body_count"
          set ::__aa_test_indent [info level]
          set catch_val [catch $testcase_body msg]
          if {$catch_val != 0 && $catch_val != 2} {
              aa_log_result "fail" "category_object_mapping (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: