X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Ft%2Fweb%2Fhtml_template.t;h=108d83fa1a4052430d451d803c353295ab932614;hb=958c9aaf69a633eb6acdf81608c35963681e3a18;hp=662a26bbdc7d20af5c6d74b4bc5d2f52e92a7dad;hpb=85e677b86fc37c54e6de2b06340351a28f5a5916;p=freeside.git diff --git a/rt/t/web/html_template.t b/rt/t/web/html_template.t index 662a26bbd..108d83fa1 100644 --- a/rt/t/web/html_template.t +++ b/rt/t/web/html_template.t @@ -1,39 +1,38 @@ -#!/usr/bin/perl use strict; use warnings; -use RT::Test tests => 19; -use Encode; +use RT::Test tests => undef; my ( $baseurl, $m ) = RT::Test->started_ok; ok $m->login, 'logged in as root'; -use utf8; - diag('make Autoreply template a html one and add utf8 chars') if $ENV{TEST_VERBOSE}; +my $template = Encode::decode("UTF-8", "你好 éèà€"); +my $subject = Encode::decode("UTF-8", "标题"); +my $content = Encode::decode("UTF-8", "测试"); { - $m->follow_link_ok( { id => 'tools-config-global-templates' }, '-> Templates' ); - $m->follow_link_ok( { text => 'Autoreply' }, '-> Autoreply' ); + $m->follow_link_ok( { id => 'admin-global-templates' }, '-> Templates' ); + $m->follow_link_ok( { text => 'Autoreply in HTML' }, '-> Autoreply in HTML' ); $m->submit_form( form_name => 'ModifyTemplate', fields => { - Content => <<'EOF', -Subject: AutoReply: {$Ticket->Subject} + Content => <Subject} Content-Type: text/html -你好 éèà€ -{$Ticket->Subject} +$template +{\$Ticket->Subject} ------------------------------------------------------------------------- -{$Transaction->Content()} +{\$Transaction->Content()} EOF }, ); - $m->content_like( qr/Content changed/, 'content is changed' ); - $m->content_contains( '你好', 'content is really updated' ); + $m->content_like( qr/Content updated/, 'content is changed' ); + $m->content_contains( $template, 'content is really updated' ); } diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE}; @@ -43,17 +42,16 @@ diag('create a ticket to see the autoreply mail') if $ENV{TEST_VERBOSE}; $m->submit_form( form_name => 'TicketCreate', - fields => { Subject => '标题', Content => '

测试

', + fields => { Subject => $subject, Content => "

$content

", ContentType => 'text/html' }, ); $m->content_like( qr/Ticket \d+ created/i, 'created the ticket' ); $m->follow_link( text => 'Show' ); - $m->content_contains( '你好', 'html has 你好' ); - $m->content_contains( 'éèà€', 'html has éèà€' ); - $m->content_contains( '标题', - 'html has ticket subject 标题' ); - $m->content_contains( '<h1>测试</h1>', - 'html has ticket html content 测试' ); + $m->content_contains( $template, "html has $template" ); + $m->content_contains( $subject, + "html has ticket subject $subject" ); + $m->content_contains( "<h1>$content</h1>", + "html has ticket html content $content" ); } diag('test real mail outgoing') if $ENV{TEST_VERBOSE}; @@ -62,11 +60,12 @@ diag('test real mail outgoing') if $ENV{TEST_VERBOSE}; # $mail is utf8 encoded my ($mail) = RT::Test->fetch_caught_mails; - $mail = decode_utf8 $mail; - like( $mail, qr/你好.*你好/s, 'mail has éèà€' ); - like( $mail, qr/éèà€.*éèà€/s, 'mail has éèà€' ); - like( $mail, qr/标题.*标题/s, 'mail has ticket subject 标题' ); - like( $mail, qr/测试.*测试/s, 'mail has ticket content 测试' ); - like( $mail, qr!

测试

!, 'mail has ticket html content 测试' ); + $mail = Encode::decode("UTF-8", $mail ); + like( $mail, qr/$template.*$template/s, 'mail has template content $template twice' ); + like( $mail, qr/$subject.*$subject/s, 'mail has ticket subject $sujbect twice' ); + like( $mail, qr/$content.*$content/s, 'mail has ticket content $content twice' ); + like( $mail, qr!

$content

!, 'mail has ticket html content

$content

' ); } +undef $m; +done_testing;