_notifications__notification_display_tests (private)
_notifications__notification_display_tests
Defined in packages/notifications/tcl/test/notifications-test-procs.tcl
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: set _aa_export {} set body_count 1 foreach testcase_body {{ aa_run_with_teardown -rollback -test_code { # Entire forum set spec { contract_name "NotificationType" owner "notifications" name "notifications_test_notif_type" pretty_name "Notifications Test Notification Type" aliases { GetURL { alias notification::test::notification__get_url language TCL } ProcessReply { alias notification::test::notification__process_reply language TCL } } } set sc_impl_id [acs_sc::impl::new_from_spec -spec $spec] set short_name "notifications_test_notif" set pretty_name "Test Notifications" set description "These dummy notification type is created during automated tests." set type_id [notification::type::new -sc_impl_id $sc_impl_id -short_name $short_name -pretty_name $pretty_name -description $description -all_intervals -all_delivery_methods] set object_id [db_string q {select object_id from acs_objects fetch first 1 rows only}] set user_id [db_string q {select user_id from users fetch first 1 rows only}] set return_url my-test-url aa_log "Generate subscribe URL" set subscribe_url [notification::display::subscribe_url -type $short_name -object_id $object_id -url $return_url -user_id $user_id -pretty_name $pretty_name] aa_false "Returned URL is our own" [util::external_url_p $subscribe_url] foreach p {type_id user_id object_id pretty_name return_url} { aa_true "Returned URL contains the expected information $p" [string match *[ns_urlencode [set p]]* $subscribe_url] } set delivery_methods [notification::get_delivery_methods -type_id $type_id] set intervals [notification::get_intervals -localized -type_id $type_id] set one_delivery_method_id [lindex $delivery_methods 0 1] set one_interval_id [lindex $intervals 0 1] aa_log "Create a subscription" set request_id [notification::request::new -type_id $type_id -user_id $user_id -object_id $object_id -interval_id $one_interval_id -delivery_method_id $one_delivery_method_id] aa_log "Generate the unsubscribe URL" set unsubscribe_url [notification::display::unsubscribe_url -request_id $request_id -url $return_url] aa_false "Returned URL is our own" [util::external_url_p $subscribe_url] foreach p {request_id return_url} { aa_true "Returned URL contains the expected information $p" [string match *[ns_urlencode [set p]]* $unsubscribe_url] } set root_path [apm_package_url_from_key [notification::package_key]] aa_log "Generate the subscription URL we expect from notification::display::subscribe_url" set subscribe_url_api [notification::display::subscribe_url -type $short_name -object_id $object_id -url $return_url -user_id $user_id -pretty_name $pretty_name] aa_equals "The API returns the expected subscription URL" $subscribe_url_api [export_vars -base "${root_path}request-new" { type_id user_id object_id pretty_name return_url }] aa_log "Generate the subscription URL we expect from notification::display::get_urls" set subscribe_url [export_vars -base "${root_path}request-new" { type_id object_id pretty_name return_url }] aa_log "Generate the two URLs" set urls [notification::display::get_urls -type $short_name -object_id $object_id -return_url $return_url -pretty_name $pretty_name -user_id $user_id] aa_equals "Subscribe URL is empty because user '$user_id' has subscribed" "" [lindex $urls 0] aa_equals "Unsubscribe URL is correct" $unsubscribe_url [lindex $urls 1] aa_log "Generate the request widget" set widget [notification::display::request_widget -type $short_name -object_id $object_id -pretty_name $pretty_name -url $return_url -user_id $user_id] aa_true "The widget is HTML" [ad_looks_like_html_p $widget] aa_false "Widget does not contain the subscribe URL" [string match *[ns_quotehtml $subscribe_url_api]* $widget] aa_true "Widget contains the unsubscribe URL" [string match *[ns_quotehtml $unsubscribe_url]* $widget] aa_log "Unsubscribe user '$user_id'" notification::request::delete -request_id $request_id aa_log "Generate the two URLs again" set urls [notification::display::get_urls -type $short_name -object_id $object_id -return_url $return_url -pretty_name $pretty_name -user_id $user_id] aa_equals "Unsubscribe URL is empty because user '$user_id' has not subscribed" "" [lindex $urls 1] aa_equals "Subscribe URL is correct" $subscribe_url [lindex $urls 0] aa_log "Generate the request widget again" set widget [notification::display::request_widget -type $short_name -object_id $object_id -pretty_name $pretty_name -url $return_url -user_id $user_id] aa_true "The widget is HTML" [ad_looks_like_html_p $widget] aa_true "Widget contains the subscribe URL" [string match *[ns_quotehtml $subscribe_url_api]* $widget] aa_false "Widget does not contain the unsubscribe URL" [string match *[ns_quotehtml $unsubscribe_url]* $widget] } }} { 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" "notification_display_tests (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle