xowiki::test::require_test_folder (public)

 xowiki::test::require_test_folder -instance instance \
    -folder_name folder_name [ -user_id user_id ] \
    [ -last_request last_request ] [ -form_name form_name ] [ -fresh ] \
    [ -update update ] [ -extra_url_parameter extra_url_parameter ]

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

Make sure a testfolder with the specified name exists in the top level directory of the specified instance. If this folder exists already, it is deleted are recreated empty.

Switches:
-instance
(required)
the path leading the instance, e.g. /xowiki
-folder_name
(required)
the name of the folder, e.g. "testfolder"
-user_id
(defaults to "0") (optional)
the user, under which the operations should be performed
-last_request
(optional)
-form_name
(defaults to "folder.form") (optional)
-fresh
(boolean) (defaults to "false") (optional)
create a fresh folder, this means, delete a pre-existing folder first
-update
(optional)
-extra_url_parameter
(optional)
Returns:
folder_id

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_composite_test_item create_composite_test_item (test xowf) xowiki::test::require_test_folder xowiki::test::require_test_folder test_create_composite_test_item->xowiki::test::require_test_folder test_create_folder_with_page create_folder_with_page (test xowf) test_create_folder_with_page->xowiki::test::require_test_folder test_create_form_with_form_instance create_form_with_form_instance (test xowiki) test_create_form_with_form_instance->xowiki::test::require_test_folder test_create_form_with_numeric create_form_with_numeric (test xowiki) test_create_form_with_numeric->xowiki::test::require_test_folder test_create_test_items create_test_items (test ) test_create_test_items->xowiki::test::require_test_folder _ _ (public) xowiki::test::require_test_folder->_ aa_log aa_log (public) xowiki::test::require_test_folder->aa_log acs::test::get_url_from_location acs::test::get_url_from_location (public) xowiki::test::require_test_folder->acs::test::get_url_from_location acs::test::http acs::test::http (public) xowiki::test::require_test_folder->acs::test::http acs::test::reply_has_status_code acs::test::reply_has_status_code (public) xowiki::test::require_test_folder->acs::test::reply_has_status_code

Testcases:
create_test_items, xowf, create_composite_test_item, create_folder_with_page, create_workflow_with_instance, create_form_with_form_instance, create_form_with_numeric, form_validate
Source code:
        set must_create 1
        ::xo::Package initialize -url $instance/

        #
        # First check, if test folder exists already.
        #
        set d [acs::test::http -last_request $last_request -user_id $user_id $instance/$folder_name]
        if {[dict get $d status] == 200} {
            #
            # yes it exists - so delete it
            #
            if {$fresh_p} {
                #
                # Since -fresh was specified, we delete the folder and
                # create it later again.
                #
                aa_log "require_test_folder_ test folder $folder_name exists already, ... delete it (user_id $user_id)"
                set d [acs::test::http -last_request $last_request -user_id $user_id  $instance/$folder_name?m=delete&return_url=$instance/]
                if {[acs::test::reply_has_status_code $d 302]} {
                    set location [::acs::test::get_url_from_location $d]
                    set d [acs::test::http -last_request $last_request -user_id $user_id $location/]
                    acs::test::reply_has_status_code $d 200
                }
            } else {
                set must_create 0
            }
        }

        if {$must_create} {
            aa_log "require_test_folder: create a fresh test folder $folder_name"
            #
            # When we try folder creation without being logged in, we
            # expect a permission denied error.
            #
            set d [acs::test::http -user_id 0 $instance/$form_name?m=create-new&return_url=$instance/]
            acs::test::reply_has_status_code $d 403

            ::xowiki::test::create_form_page  -user_id $user_id  -last_request $last_request  -instance $instance  -path ""  -autonamed  -parent_id [::$package_id folder_id]  -form_name $form_name  -update [subst {
                    _title "Test folder"
                    _name $folder_name
                    $update
                }]  -extra_url_parameter $extra_url_parameter
        }

        set new_folder_id [::$package_id lookup -name $folder_name]
        aa_log "require_test_folder: set folder_id [::$package_id lookup -name $folder_name] ==> $new_folder_id DONE"

        return [list folder_id $new_folder_id package_id $package_id]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: