X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05template.t;h=ab5abe4ea4822a2662ebf3aa3bd02aa041ae3ada;hb=502b560653fd758241e2b597ac0849745704365c;hp=688f672e9fdc085bfcfd6e13cc14ccd21c5eb6ae;hpb=fd0033bcce7b7449047642b4ced675fded5aae64;p=catagits%2FCatalyst-View-Email.git diff --git a/t/05template.t b/t/05template.t index 688f672..ab5abe4 100644 --- a/t/05template.t +++ b/t/05template.t @@ -1,28 +1,39 @@ use strict; use warnings; -use Test::More tests => 10; -use Email::Send::Test; +BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' } +use Test::More; + +use Email::Sender::Simple; use FindBin; use lib "$FindBin::Bin/lib"; +eval "use Catalyst::View::TT"; +if ( $@ ) { + plan skip_all => 'Catalyst::View::TT required for Template tests'; + exit; +} + use_ok('Catalyst::Test', 'TestApp'); my $response; my $time = time; ok( ( $response = request("/template_email?time=$time"))->is_success, 'request ok' ); +my @emails = Email::Sender::Simple->default_transport->deliveries; like( $response->content, qr/Template Email Ok/, 'controller says ok' ); -my @emails = Email::Send::Test->emails; - cmp_ok(@emails, '==', 1, 'got emails'); -isa_ok( $emails[0], 'Email::MIME', 'email is ok' ); -my @parts = $emails[0]->parts; +isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' ); + +like($emails[0]->{'email'}[0]->header("Content-type"), qr#^multipart/alternative#, 'Multipart email'); + +my @parts = $emails[0]->{'email'}[0]->parts; cmp_ok(@parts, '==', 2, 'got parts'); -is($parts[0]->content_type, 'text/plain; charset="us-ascii"', 'text/plain ok'); +is($parts[0]->content_type, 'text/plain', 'text/plain part ok'); like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back'); -is($parts[1]->content_type, 'text/html; charset="us-ascii"', 'text/html ok'); + +is($parts[1]->content_type, 'text/html', 'text/html ok'); like($parts[1]->body, qr{test-email\@example.com on $time}, 'got content back'); #like($emails[0]->body, qr/$time/, 'Got our email'); - +done_testing();