_xowiki__link_tests (private)
_xowiki__link_tests
Defined in packages/xowiki/tcl/test/xowiki-link-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 {{ # # Set up of the test case. # set main_xowiki_instance_name /xowiki-test set linked_xowiki_instance_name /xowiki-test-linked set main_package_id [::acs::test::require_package_instance -package_key xowiki -empty -instance_name $main_xowiki_instance_name] set linked_package_id [::acs::test::require_package_instance -package_key xowiki -empty -instance_name $linked_xowiki_instance_name] aa_log main_package_id=$main_package_id aa_log linked_package_id=$linked_package_id foreach parameter {MenuBar MenuBarSymLinks} { ::parameter::set_value -package_id $main_package_id -parameter $parameter -value 1 ::parameter::set_value -package_id $linked_package_id -parameter $parameter -value 1 } set testfolder .testfolder # # Force the system locale to en_US. We have to reset the # locale at the end of this run, since we have no # transaction. # set defined_locale [lang::system::locale] lang::system::set_locale en_US set locale [lang::system::locale] set lang [string range $locale 0 1] # # Perform a full initialize on both packages to get ::xo::cc # also set. # ::xowiki::Package initialize -package_id $main_package_id ::xowiki::Package initialize -package_id $linked_package_id set main_root_folder_id [::$main_package_id folder_id] set linked_root_folder_id [::$linked_package_id folder_id] set link_name link-to-folder-with-no-index-page set linked_folder_name folder-with-no-index-page set linked_folder_id [xowiki::test::require_folder $linked_folder_name $linked_root_folder_id $linked_package_id] aa_true "linked_folder_id $linked_folder_id is valid " {$linked_folder_id ne "0"} set link_id [xowiki::test::require_link $link_name $main_root_folder_id $main_package_id /$linked_xowiki_instance_name/$linked_folder_name] aa_true "link_id $link_id is valid " {$link_id ne "0"} set p1_id [xowiki::test::require_page en:p1 $linked_folder_id $linked_package_id] aa_true "link_id $p1_id is valid " {$p1_id ne "0"} ::xo::db::CrClass get_instance_from_db -item_id $link_id set link_content [::$link_id render_content] #ns_log notice $link_content aa_section "Check links in rendered child-resources (default render_local)" # # Check, if # (a) the rendered link contains the page included in the linked folder and # (b) that the page link points to the target instance (no resolve_local provided) # aa_log "check content of /$linked_xowiki_instance_name/$linked_folder_name" #ns_log notice "search for link with title en:p1: link_content $link_content" acs::test::dom_html root $link_content { set node [$root selectNodes //td\[@class='list'\]/a\[@title='en:p1'\]] aa_true "one page found" {[llength $node] == 1} if {[llength $node] == 1} { set href [$node getAttribute href] aa_equals "href points to linked folder" $href $linked_xowiki_instance_name/$linked_folder_name/p1 } } aa_section "Check links in rendered child-resources (default render_local=true)" # # Now we test the behavior, if the link is defined with # "resolve_local=true". Since the defining is coming from # the site-wide-pages, and many of these values are # already loaded, we modify the loaded content. In # particular, the form-field responsible for rendering can # be looked up, and we can modify in this form-field the # instance variable "resolve_local" directly. # # This is by-passing the API, but little code. Caveat: # When form-field caching is modified, we might have to # change this code as well foreach f [::xowiki::formfield::FormField info instances -closure] { if {[$f name] eq "link"} { $f set resolve_local true } } acs::test::dom_html root [::$link_id render_content] { set node [$root selectNodes //td\[@class='list'\]/a\[@title='en:p1'\]] aa_true "one page found" {[llength $node] == 1} if {[llength $node] == 1} { set href [$node getAttribute href] aa_equals "href points to local folder" $href $main_xowiki_instance_name/$link_name/p1 } } # # reset system locale to saved value # lang::system::set_locale $defined_locale }} { 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" "link_tests (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo" } incr body_count }XQL Not present: Generic, PostgreSQL, Oracle