_categories__category_crud (private)

 _categories__category_crud

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

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

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

    aa_run_with_teardown  -rollback  -test_code {

            set locale it_IT

            aa_section "Create tree"
            set tree_id [category_tree::add  -name "foo" -locale $locale]

            category_tree::update  -tree_id $tree_id  -locale de_DE  -name föö  -description Descriptiön
            aa_equals "category_tree::get_translation returns expected"  [category_tree::get_translation $tree_id de_DE]  [list "föö" "Descriptiön"]

            aa_section "Create category"
            set category_id [category::add  -tree_id $tree_id  -parent_id ""  -locale $locale  -name "foo"]

            aa_equals "Name is right"  [category::get_name $category_id $locale] foo

            aa_section "Update category"
            category::update  -category_id $category_id  -name boo  -locale $locale  -description something
            set attrs [category::get  -category_id $category_id  -locale $locale]
            aa_equals "name is as expected"  [dict get $attrs name] boo
            aa_equals "Description is as expected"  [dict get $attrs description] something

            set category_child_1 [category::add  -tree_id $tree_id  -parent_id $category_id  -locale $locale  -name "foo child 1"]
            set category_child_2 [category::add  -tree_id $tree_id  -parent_id $category_id  -locale $locale  -name "foo child 2"]

            aa_equals "Category '$category_id' has 2 visible children"  [llength [category::get_children -category_id $category_id]]  2

            category_tree::get_multirow  -tree_id $tree_id  -datasource __test_category_crud

            aa_true "Multirow __test_category_crud exists"  [::template::multirow exists __test_category_crud]
            aa_equals "Multirow __test_category_crud has 3 rows"  [::template::multirow size __test_category_crud]  3
            set result [list]
            ::template::multirow -unclobber foreach __test_category_crud {
                lappend result  $tree_id  $tree_name  $category_id  $category_name  $level  $pad  $deprecated_p  $count  $child_sum
            }
            aa_equals "Multirow returns expected"  [list  $tree_id foo $category_id foo 1 {} f 0 0  $tree_id foo $category_child_1 {foo child 1} 2 .. f 0 0  $tree_id foo $category_child_2 {foo child 2} 2 .. f 0 0]  $result

            aa_log "Phase out child '$category_child_1'"
            category::phase_out $category_child_1

            aa_equals "Category '$category_id' has 1 visible child"  [llength [category::get_children -category_id $category_id]]  1

            aa_log "Phase out child '$category_child_2'"
            category::phase_out $category_child_2

            aa_equals "Category '$category_id' has 0 visible children"  [llength [category::get_children -category_id $category_id]]  0

            aa_equals "category_tree::get_tree returns expected (pre-flush)"  [category_tree::get_tree -all $tree_id]  [list  [list $category_id foo f 1]  [list $category_child_1 {foo child 1} f 2]  [list $category_child_2 {foo child 2} f 2]  ]

            aa_log "Flush cache"
            category_tree::reset_cache

            aa_equals "category_tree::get_tree returns expected (post-flush)"  [category_tree::get_tree -all $tree_id]  [list  [list $category_id foo f 1]  [list $category_child_1 {foo child 1} t 2]  [list $category_child_2 {foo child 2} t 2]  ]

            category_tree::get_multirow  -tree_id $tree_id  -datasource __test_category_crud

            aa_true "Multirow __test_category_crud exists"  [::template::multirow exists __test_category_crud]
            aa_equals "Multirow __test_category_crud has 1 row (phased out categories skipped)"  [::template::multirow size __test_category_crud]  1

            aa_log "Phase children back in"
            category::phase_in $category_child_1
            category::phase_in $category_child_2

            aa_equals "Category '$category_id' has 2 visible children again"  [llength [category::get_children -category_id $category_id]]  2

            aa_log "Delete children"
            category::delete $category_child_1
            category::delete $category_child_2

            aa_section "Delete category (batch)"
            category::delete -batch_mode $category_id
            aa_false "category was deleted successfully"  [category::exists_p $category_id]
            aa_equals "Cache entry was not flushed"  [category::get_name $category_id $locale] boo

            aa_section "Flush cache"
            category::flush_translation_cache $category_id
            aa_false "Cache entry was flushed"  {[category::get_name $category_id $locale] ne ""}
        }
}} {
          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_crud (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: