_acs-content-repository__content_item_nested_structure (private)

 _acs-content-repository__content_item_nested_structure

Defined in packages/acs-content-repository/tcl/test/content-item-test-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) _acs-content-repository__content_item_nested_structure _acs-content-repository__content_item_nested_structure _acs-content-repository__content_item_nested_structure->aa_equals _acs-content-repository__content_item_nested_structure->aa_log _acs-content-repository__content_item_nested_structure->aa_log_result _acs-content-repository__content_item_nested_structure->aa_run_with_teardown _acs-content-repository__content_item_nested_structure->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 {

                #########################################################
                # create the root folder of our test structure
                #########################################################
                set root_folder_id [db_nextval "acs_object_id_seq"]
                content::folder::new  -folder_id $root_folder_id  -name "test_folder_${root_folder_id}"

                content::folder::register_content_type  -folder_id $root_folder_id  -content_type "content_revision"

                content::folder::register_content_type  -folder_id $root_folder_id  -content_type "content_folder"

                #########################################################
                # create a cr_item in the root folder
                #########################################################

                set root_item_id [db_nextval "acs_object_id_seq"]
                content::item::new  -name "test_item_$root_item_id"  -item_id $root_item_id  -parent_id $root_folder_id  -is_live t  -attributes [list [list title "test_item_$root_item_id"]]

                #########################################################
                # create a cr_folder
                #########################################################
                set first_folder_id [db_nextval "acs_object_id_seq"]
                content::folder::new  -parent_id $root_folder_id  -folder_id $first_folder_id  -name "test_folder_${first_folder_id}"

                #########################################################
                # create a cr_item in the first toplevel folder
                #########################################################

                set first_item_id [db_nextval "acs_object_id_seq"]
                content::item::new  -name "test_item_$first_item_id"  -item_id $first_item_id  -parent_id $first_folder_id  -is_live t  -attributes [list [list title "test_item_$first_item_id"]]

                #########################################################
                # create a subfolder
                #########################################################
                set sub_folder_id [db_nextval "acs_object_id_seq"]
                content::folder::new  -parent_id $first_folder_id  -folder_id $sub_folder_id  -name "test_folder_${sub_folder_id}"

                #########################################################
                # create a cr_item in the subfolder
                #########################################################

                set sub_item_id [db_nextval "acs_object_id_seq"]
                content::item::new  -name "test_item_$sub_item_id"  -item_id $sub_item_id  -parent_id $sub_folder_id  -is_live t  -mime_type text/plain  -attributes [list [list title "test_item_$sub_item_id"]]


                #########################################################
                # create another toplevel folder
                #########################################################

                set second_folder_id [db_nextval "acs_object_id_seq"]
                content::folder::new  -parent_id $root_folder_id  -folder_id $second_folder_id  -name "test_folder_${second_folder_id}"

                aa_section content::item::get_descendants

                aa_equals "Test descendants of root folder '$root_folder_id'"  [lsort [content::item::get_descendants -parent_id $root_folder_id]]  [lsort [list $root_item_id $first_item_id $first_folder_id $sub_folder_id $sub_item_id $second_folder_id]]

                aa_equals "Test descendants up to depth 1 of root folder '$root_folder_id'"  [lsort [content::item::get_descendants -depth 1 -parent_id $root_folder_id]]  [lsort [list $root_item_id $first_folder_id $second_folder_id]]

                aa_equals "Test descendants up to depth 2 of root folder '$root_folder_id'"  [lsort [content::item::get_descendants -depth 2 -parent_id $root_folder_id]]  [lsort [list $root_item_id $first_item_id $first_folder_id $sub_folder_id $second_folder_id]]

                aa_equals "Test descendants of folder '$first_folder_id'"  [lsort [content::item::get_descendants -parent_id $first_folder_id]]  [lsort [list $first_item_id $sub_folder_id $sub_item_id]]

                aa_equals "Test descendants up to depth 1 of folder '$first_folder_id'"  [lsort [content::item::get_descendants -depth 1 -parent_id $first_folder_id]]  [lsort [list $first_item_id $sub_folder_id]]

                aa_equals "Test descendants of folder '$second_folder_id'" "" ""


                aa_section content::item::get_path

                aa_equals "Test path of root folder '$root_folder_id'"  [content::item::get_path -item_id $root_folder_id]  /pages/test_folder_$root_folder_id

                aa_equals "Test path of item '$sub_item_id'"  [content::item::get_path -item_id $sub_item_id]  /pages/test_folder_$root_folder_id/test_folder_$first_folder_id/test_folder_$sub_folder_id/test_item_$sub_item_id

                aa_equals "Test path of item '$sub_item_id' starting from folder '$first_folder_id'"  [content::item::get_path -item_id $sub_item_id -root_folder_id $first_folder_id]  test_folder_$sub_folder_id/test_item_$sub_item_id

                aa_equals "Test path of item '$first_item_id'"  [content::item::get_path -item_id $first_item_id]  /pages/test_folder_$root_folder_id/test_folder_$first_folder_id/test_item_$first_item_id

                aa_section content::item::get_virtual_path

                #
                # Note: we are not testing symlinks so far, so
                # content::item::get_virtual_path will behave the same
                # as content::item::get_path.
                #

                aa_equals "Test path of root folder '$root_folder_id'"  [content::item::get_virtual_path -item_id $root_folder_id]  /pages/test_folder_$root_folder_id

                aa_equals "Test path of item '$sub_item_id'"  [content::item::get_virtual_path -item_id $sub_item_id]  /pages/test_folder_$root_folder_id/test_folder_$first_folder_id/test_folder_$sub_folder_id/test_item_$sub_item_id

                aa_equals "Test path of item '$sub_item_id' starting from folder '$first_folder_id'"  [content::item::get_virtual_path -item_id $sub_item_id -root_folder_id $first_folder_id]  test_folder_$sub_folder_id/test_item_$sub_item_id

                aa_equals "Test path of item '$first_item_id'"  [content::item::get_virtual_path -item_id $first_item_id]  /pages/test_folder_$root_folder_id/test_folder_$first_folder_id/test_item_$first_item_id


                aa_section content::item::get_publish_date

                set all_items [list $root_item_id $first_item_id $first_folder_id $sub_folder_id $sub_item_id $second_folder_id]
                foreach is_live {t f} {
                    foreach item_id $all_items {
                        set expected [db_string get_publish_date {
                            select r.publish_date
                              from cr_revisions r,
                                   cr_items i
                             where i.item_id = :item_id
                               and i.item_id = r.item_id
                               and ((:is_live = 't' and r.revision_id = i.live_revision) or
                                    (:is_live = 'f' and r.revision_id = i.latest_revision)
                                    )
                        } -default ""]
                        aa_equals "content::item::get_publish_date -item_id $item_id -is_live $is_live returns expected"  [content::item::get_publish_date -item_id $item_id -is_live $is_live]  $expected
                        aa_true "Empty publish date means the item is a folder (no revisions)"  [expr {$expected ne "" || [content::folder::is_folder -item_id $item_id]}]
                    }
                }

                aa_section content::item::get_publish_status

                set all_items [list $root_item_id $first_item_id $first_folder_id $sub_folder_id $sub_item_id $second_folder_id]
                foreach item_id $all_items {
                    set expected [db_string get_publish_status {
                        select publish_status from cr_items where item_id = :item_id
                    }]
                    aa_equals "content::item::get_publish_status -item_id $item_id returns expected"  [content::item::get_publish_status -item_id $item_id]  $expected

                    foreach status {"production" "ready" "live" "expired"} {
                        aa_log "Set publish statut on '$item_id' to '$status'"
                        content::item::unpublish -item_id $item_id -publish_status $status

                        aa_equals "New publish status for '$item_id' is '$status'"  [content::item::get_publish_status -item_id $item_id]  $status

                        #
                        # To count as published, the item must have
                        # revisions (e.g. a folder cannot be
                        # published) and be in the 'live' status.
                        #
                        set is_published [expr {[content::item::is_published -item_id $item_id] ? 1 : 0}]
                        aa_true "Check if item '$item_id' counts as published" {
                            $is_published == ($status eq "live") ||
                            [content::folder::is_folder -item_id $item_id]
                        }
                    }
                }

                aa_section content::item::get_root_folder

                #
                # Note: what we call "root_folder" in out test setup
                # is the root of our test folder tree, not the cr root
                # folder that we fetch with this api!
                #
                set api_root_folder_id [content::item::get_root_folder -item_id $root_folder_id]
                set expected_root_folder_id [db_string get_root_folder {
                    select i2.item_id
                    from cr_items i1, cr_items i2
                    where i2.parent_id = -4
                    and i1.item_id = :root_folder_id
                    and i1.tree_sortkey between i2.tree_sortkey and tree_right(i2.tree_sortkey)
                }]

                aa_equals "Root folder from api and query are the same"  $api_root_folder_id $expected_root_folder_id

                foreach item_id $all_items {
                    aa_equals "Test item '$item_id' belongs to the same root folder as the others"  $expected_root_folder_id [content::item::get_root_folder -item_id $item_id]
                }

                aa_section content::item::get_content

                content::item::get_content -item_id $sub_item_id -array content
                aa_true "Item '$sub_item_id' has a text mime type and the content array should contain the 'text' variable."  [info exists content(text)]

            }
    }} {
          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" "content_item_nested_structure (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: