_acs-templating__spellcheck__get_element_formtext (private)

 _acs-templating__spellcheck__get_element_formtext

Defined in packages/acs-templating/tcl/test/spell-checker-procs.tcl

Partial Call Graph (max 5 caller/called nodes):
%3 aa_equals aa_equals (public) aa_false aa_false (public) aa_log aa_log (public) aa_log_result aa_log_result (public) aa_true aa_true (public) _acs-templating__spellcheck__get_element_formtext _acs-templating__spellcheck__get_element_formtext _acs-templating__spellcheck__get_element_formtext->aa_equals _acs-templating__spellcheck__get_element_formtext->aa_false _acs-templating__spellcheck__get_element_formtext->aa_log _acs-templating__spellcheck__get_element_formtext->aa_log_result _acs-templating__spellcheck__get_element_formtext->aa_true

Testcases:
No testcase defined.
Source code:
        
        set _aa_export {}
        set body_count 1
        foreach testcase_body {{    
    

    set SpellcheckFormWidgets [parameter::get_from_package_key  -package_key acs-templating  -parameter SpellcheckFormWidgets]
    set enabled 0
    foreach {widget value} $SpellcheckFormWidgets {
    if {!$value} continue
    set enabled 1
    break
    }

    if {!$enabled} {
    aa_log "Spell checking is not enabled. If you want to enable it, specify it via package parameter SpellcheckFormWidgets"
    return
    }

    set base_command [list template::util::spellcheck::get_element_formtext  -var_to_spellcheck var_to_spellcheck  -error_num_ref error_num  -no_abort  -formtext_to_display_ref formtext_to_display  -just_the_errwords_ref just_the_errwords]
    
    #####
    #
    # Plain text without spelling mistakes
    #
    #####

    set command $base_command
    lappend command -text "This sentence does not contain any misspelled words. What we have here is plain text."
    
    aa_log "--- Correct text --- $command"

    if {[catch {eval $command} errorMsg]} {
    aa_false $errorMsg 1
    aa_log "Have you installed aspell and aspell-dict-en ?"
    return
    }
    aa_true "True statement: Text contains no misspelled words" {$error_num == 0}
    
    aa_log "Number of miss-spelled words found in text: $error_num"
    aa_false "False statement: Text contains misspelled word(s)" {$error_num > 0}
    
    aa_equals "Number of misspelled words found in text" $error_num 0
    aa_log "Returned string: $formtext_to_display"
    
    aa_true "The returned string contains a hidden var named 'var_to_spellcheck.merge_text'"  [regexp "var_to_spellcheck.merge_text" $formtext_to_display]

    aa_true "The returned string contains no hidden var(s) named 'var_to_spellcheck.error_N', where N is the error number."  ![regexp "var_to_spellcheck.error_\[0-9\]*" $formtext_to_display]

    aa_true "just_the_errwords is empty" {$just_the_errwords eq ""}
    
    #####
    #
    # Plain text with spelling mistakes
    #
    #####
    
    set command $base_command
    lappend command -text "I obviosly can't spel very well ..."
    set errwords {obviosly spel}
    
    aa_log "--- Incorrect text --- $command"

    if {[catch {eval $command} errorMsg]} {
    aa_false $errorMsg 1
    return
    }
 
    aa_true "True statement: Text contains misspelled words" {$error_num > 0}
    
    aa_log "Number of misspelled words found in text: $error_num"
    aa_false "False statement: Text contains no misspelled word(s)" {$error_num == 0}
    
    aa_log "Returned string: $formtext_to_display"
    aa_true "The returned string contains a hidden var named 'var_to_spellcheck.merge_text'"  [regexp "var_to_spellcheck.merge_text" $formtext_to_display]

    aa_true "The returned string contains $error_num hidden var(s) named 'var_to_spellcheck.error_N', where N is a number between 0 and [expr {$error_num - 1}]."  [regexp "var_to_spellcheck.error_\[0-9\]*" $formtext_to_display]

    aa_equals "The number of misspelled words matches the number of error placeholders in the merge_text"  [regexp -all "var_to_spellcheck.error_\[0-9\]*" $formtext_to_display]  [regexp -all "\#\[0-9\]*\#" $formtext_to_display]

    aa_true "just_the_errwords contains the errwords we expected: '[join $errwords ""]'"  [util_sets_equal_p $just_the_errwords $errwords]

    #####
    #
    # HTML without spelling mistakes
    #
    #####

    set command $base_command
    lappend command -text "This <i>sentence</i> does <b>not</b> contain <u>any</u> misspelled words. What we have here is <a href=\"\#\">HTML</a>."
    lappend command -html
    
    aa_log "--- Correctly spelled HTML fragment --- $command"

    if {[catch {eval $command} errorMsg]} {
    aa_false $errorMsg 1
    aa_log "Maybe you have to install aspell and aspell-dict-en?"
    return
    }
    
    aa_true "True statement: HTML fragment contains no misspelled words" {$error_num == 0}
    
    aa_log "Number of miss-spelled words found in HTML fragment: $error_num"
    aa_false "False statement: HTML fragment contains misspelled word(s)" {$error_num > 0}
    
    aa_equals "Number of misspelled words found in HTML fragment" $error_num 0
    
    aa_log "Returned string: $formtext_to_display"
    aa_true "The returned string contains a hidden var named 'var_to_spellcheck.merge_text'"  [regexp "var_to_spellcheck.merge_text" $formtext_to_display]

    aa_true "The returned string contains no hidden var(s) named 'var_to_spellcheck.error_N', where N is the error number."  ![regexp "var_to_spellcheck.error_\[0-9\]*" $formtext_to_display]

    aa_true "just_the_errwords is empty" {$just_the_errwords eq ""}

    #####
    #
    # HTML with spelling mistakes
    #
    #####

    set command $base_command
    lappend command -text "This <i>sentence</i> <b>does</b> contain misspelled worrds. What we have here is <a href=\"\#\">HTML</a>."
    lappend command -html
    set errwords {misspelled worrds}
    
    aa_log "--- Incorrectly spelled HTML fragment --- $command"

    if {[catch {eval $command} errorMsg]} {
    aa_false $errorMsg 1
    return
    }

    aa_true "True statement: HTML fragment contains misspelled words" {$error_num > 0}
    
    aa_log "Number of miss-spelled words found in HTML fragment: $error_num"
    
    aa_false "False statement: HTML fragment contains no misspelled word(s)" {$error_num == 0}
    
    aa_log "Returned string: $formtext_to_display"
    
    aa_true "The returned string contains a hidden var named 'var_to_spellcheck.merge_text'"  [regexp "var_to_spellcheck.merge_text" $formtext_to_display]

    aa_true "The returned string contains hidden var(s) named 'var_to_spellcheck.error_N', where N is the error number."  [regexp "var_to_spellcheck.error_\[0-9\]*" $formtext_to_display]

    aa_true "just_the_errwords contains the errwords we expected: '[join $errwords ""]'"  [util_sets_equal_p $just_the_errwords $errwords]

}} {
          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" "spellcheck__get_element_formtext (body $body_count): Error during execution: $msg, stack trace: \n$::errorInfo"
          }
          incr body_count
        }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: