xowiki::test::create_form (public)

 xowiki::test::create_form [ -user_id user_id ] \
    [ -last_request last_request ] -instance instance -path path \
    -parent_id parent_id -name name [ -autonamed ] [ -update update ] \
    [ -remove remove ]

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

Create a form via the web interface.

Switches:
-user_id (optional, defaults to "0")
-last_request (optional)
-instance (required)
-path (required)
-parent_id (required)
-name (required)
-autonamed (optional, boolean, defaults to "false")
-update (optional)
-remove (optional)

Partial Call Graph (max 5 caller/called nodes):
%3 test_create_form_with_form_instance create_form_with_form_instance (test xowiki) xowiki::test::create_form xowiki::test::create_form test_create_form_with_form_instance->xowiki::test::create_form test_create_form_with_numeric create_form_with_numeric (test xowiki) test_create_form_with_numeric->xowiki::test::create_form test_create_workflow_with_instance create_workflow_with_instance (test ) test_create_workflow_with_instance->xowiki::test::create_form test_form_validate form_validate (test xowiki) test_form_validate->xowiki::test::create_form test_xowf xowf (test ) test_xowf->xowiki::test::create_form aa_false aa_false (public) xowiki::test::create_form->aa_false aa_log aa_log (public) xowiki::test::create_form->aa_log aa_true aa_true (public) xowiki::test::create_form->aa_true acs::test::dom_html acs::test::dom_html (public) xowiki::test::create_form->acs::test::dom_html acs::test::form_reply acs::test::form_reply (public) xowiki::test::create_form->acs::test::form_reply

Testcases:
create_workflow_with_instance, xowf, create_form_with_form_instance, create_form_with_numeric, form_validate
Source code:
        #
        # Create a form under the parent_id
        #
        aa_log "create a new form in the test folder $parent_id"
        #
        # New form creation happens over the top-level URL
        #
        #set d [acs::test::http  #           -last_request $last_request -user_id $user_id  #           $instance/?object_type=::xowiki::Form&edit-new=1&parent_id=$parent_id&return_url=$instance/$path]

        set d [acs::test::http  -last_request $last_request -user_id $user_id  $instance/form.form?m=create-new&parent_id=$parent_id&return_url=$instance/$path]
        #
        # If we use form.form, we get a redirect; classical
        # "object_type=::xowiki::Form&edit-new=1" has no redirect.
        #
        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
            set formform 1

            set response [::xowiki::test::get_content $d]
            #ns_log notice response=$response
            set formCSSClass "Form-form"

            acs::test::dom_html root $response {

                set selector [subst {string(//form\[contains(@class,'$formCSSClass')\]//button\[@type='submit'\])}]
                set f_submit [$root selectNodes $selector]
                aa_true "submit_button '$f_submit' is non empty" {$f_submit ne ""}

                set f_id     [::xowiki::test::get_object_name $root]
                aa_false "page_id '$f_id' is empty" {$f_id eq ""}
            }
            set form [acs::test::get_form $response "//form\[contains(@class,'$formCSSClass')\]"]
            ns_log notice "FORM <$form>"

            set f_page_name   [dict get $form fields _name]
            set f_creator     [dict get $form fields _creator]
        } else {
            acs::test::reply_has_status_code $d 200
            set formform 0

            set response [dict get $d body]
            #ns_log notice response=$response
            set formCSSClass "margin-form"

            acs::test::dom_html root $response {

                set selector [subst {string(//form\[contains(@class,'$formCSSClass')\]//input\[@type='submit'\]/@value)}]
                set f_submit [$root selectNodes $selector]
                aa_true "submit_button '$f_submit' is non empty" {$f_submit ne ""}

                set f_id     [::xowiki::test::get_object_name $root]
                aa_true "page_id '$f_id' is empty" {$f_id eq ""}
            }
            set form [acs::test::get_form $response "//form\[contains(@class,'$formCSSClass')\]"]
            ns_log notice "FORM <$form>"

            set f_page_name   [dict get $form fields name]
            set f_creator     [dict get $form fields creator]
        }

        set f_form_action [dict get $form @action]

        aa_true "name '$f_page_name' is empty"             {$f_page_name eq ""}
        #aa_log  "creator '$f_creator'"
        aa_true "creator '$f_creator' is nonempty"         {$f_creator ne ""}
        aa_true "form_action '$f_form_action' is nonempty" {$f_form_action ne ""}

        set form_content [dict get $form fields]
        set names [dict keys $form_content]
        aa_log "form names: [lsort $names]"
        aa_true "page has at least 9 fields" { [llength $names] >= 9 }

        aa_log "empty form_content:\n$[::xowiki::test::pretty_form_content $form_content]"
        dict set form_content [expr {$formform ? "_name" : "name"}] $name
        set form [acs::test::form_set_fields $form $form_content]

        set d [::acs::test::form_reply  -last_request $last_request -user_id $user_id  -form $form  -update $update  -remove $remove]
        acs::test::reply_has_status_code $d 302

        foreach {key value} $update {
            dict set form_content $key $value
        }
        aa_log "form_content:\n[::xowiki::test::pretty_form_content $form_content]"

        if {[dict get $d status] eq 200} {
            set response [dict get $d body]
            ns_log notice "Maybe a validation error? response\n$response"
        }

        set location [::acs::test::get_url_from_location $d]
        aa_true "location '$location' is valid" {$location ne ""}

        ::xo::Package initialize -url $location
        set page_info [::$package_id item_ref  -default_lang en  -parent_id $parent_id  $name  ]
        set item_id [dict get $page_info item_id]
        aa_log "lookup of form $name -> $item_id"
        ::xo::db::CrClass get_instance_from_db -item_id $item_id

        set d [acs::test::http  -last_request $last_request -user_id $user_id  $instance/admin/set-publish-state?state=ready&revision_id=[::$item_id revision_id]]
        acs::test::reply_has_status_code $d 302
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: