forums::test::new_postings (private)

 forums::test::new_postings [ -last_request last_request ] \
    [ -forum_id forum_id ]

Defined in packages/forums/tcl/test/webtest-procs.tcl

Add a posting to the provided forum via the web interface.

Switches:
-last_request (optional)
-forum_id (optional, defaults to "0")
Returns:
message_id

Partial Call Graph (max 5 caller/called nodes):
%3 aa_get_first_url aa_get_first_url (public) aa_log aa_log (public) aa_true aa_true (public) acs::test::follow_link acs::test::follow_link (public) acs::test::form_reply acs::test::form_reply (public) forums::test::new_postings forums::test::new_postings forums::test::new_postings->aa_get_first_url forums::test::new_postings->aa_log forums::test::new_postings->aa_true forums::test::new_postings->acs::test::follow_link forums::test::new_postings->acs::test::form_reply

Testcases:
No testcase defined.
Source code:
        set message_id 0
        set forums_page [aa_get_first_url -package_key forums]

        set d [acs::test::http  -last_request $last_request  $forums_page/message-post?forum_id=$forum_id]
        aa_log "Edit message"
        acs::test::reply_has_status_code $d 200

        #
        # Get form data from
        #
        set form_data [::acs::test::get_form [dict get $d body] {//form[@id="message"]}]
        aa_true "Found form on reply page" {[llength $form_data] > 0}

        #
        # Build reply
        #
        set subject      "subject [ad_generate_random_string]"
        set message_body "body [ad_generate_random_string 20]"

        set d [::acs::test::form_reply  -last_request $last_request  -url [dict get $form_data @action]  -update [subst {
                       subject          "$subject"
                       message_body     "$message_body"
                       message_body.format text/plain
                   }]  [dict get $form_data fields]]

        acs::test::reply_contains_no $d form-error
        aa_log "Updated message"
        acs::test::reply_has_status_code $d 302

        aa_log [dict get $form_data fields]
        set message_id [dict get $form_data fields message_id]

        #
        # Check on the forums overview page, if we find the new subject
        #
        set d [acs::test::http -last_request $d $forums_page/forum-view?forum_id=$forum_id]
        aa_log "View forum"
        acs::test::reply_has_status_code $d 200

        acs::test::reply_contains $d $subject

        #
        # Check on the forums view page, if we find the new subject and the new body
        #
        set d [acs::test::http -last_request $d $forums_page/message-view?message_id=$message_id]
        aa_log "View message"
        acs::test::reply_has_status_code $d 200

        acs::test::reply_contains $d $subject
        acs::test::reply_contains $d $message_body

        #
        # Post a reply to the last message
        #
        set d [acs::test::http -last_request $d $forums_page/message-post?parent_id=$message_id]
        set form_data [::acs::test::get_form [dict get $d body] {//form[@id="message"]}]
        aa_true "Found form on edit page for posting reply" {[llength $form_data] > 0}
        set reply_message_id [dict get $form_data fields message_id]

        set d [::acs::test::form_reply  -last_request $d  -url [dict get $form_data @action]  -update [subst {
                       message_body        "REPLY $message_body"
                       message_body.format text/plain
                   }]  [dict get $form_data fields]]
        acs::test::reply_contains_no $d form-error
        aa_log "Entered forums"
        acs::test::reply_has_status_code $d 302

        #
        # The reply should show up on the forums thread page
        #
        set d [acs::test::http -last_request $d $forums_page/message-view?message_id=$message_id]
        aa_log "Message overview"
        acs::test::reply_has_status_code $d 200
        acs::test::reply_contains $d "REPLY $message_body"

        #
        # Edit the reply
        #
        set d [acs::test::http  -last_request $d $forums_page/moderate/message-edit?message_id=$reply_message_id]
        set form_data [::acs::test::get_form [dict get $d body] {//form[@id="message"]}]
        aa_true "Found form on edit page for editing reply" {[llength $form_data] > 0}
        set old_reply_message_body [dict get $form_data fields message_body]
        set new_reply_message_body "$old_reply_message_body EDITED"
        aa_true "old message_body contains REPLY" [string match "*REPLY*" $old_reply_message_body]

        set d [::acs::test::form_reply  -last_request $d  -url [dict get $form_data @action]  -update [subst {
                       message_body        "$new_reply_message_body"
                   }]  [dict get $form_data fields]]
        acs::test::reply_contains_no $d form-error
        aa_log "Entered forums"
        acs::test::reply_has_status_code $d 302

        #
        # The edited reply should show up on the forums thread page
        #
        set d [acs::test::http -last_request $d $forums_page/message-view?message_id=$message_id]
        aa_log "Message overview"
        acs::test::reply_has_status_code $d 200
        acs::test::reply_contains $d "$new_reply_message_body"

        #
        # Delete the reply
        #
        set request [export_vars -sign -base ${forums_page}/moderate/message-delete {{message_id $reply_message_id}}]
        set d [acs::test::http -last_request $d $request]
        aa_log "Message overview"
        acs::test::reply_has_status_code $d 200
        acs::test::reply_contains $d message-delete?confirm_p

        set d [::acs::test::follow_link  -last_request $d  -base $forums_page/moderate  -label Yes]
        aa_log "Message overview"
        acs::test::reply_has_status_code $d 302

        #
        # The edited reply should no show up up on the forums thread page
        #
        set d [acs::test::http -last_request $d $forums_page/message-view?message_id=$message_id]
        aa_log "Message overview"
        acs::test::reply_has_status_code $d 200
        acs::test::reply_contains_no $d "$new_reply_message_body"

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