Commit | Line | Data |
82300460 |
1 | use strict; |
2 | use warnings; |
8b10ee55 |
3 | use Test::More; |
82300460 |
4 | |
5 | use Email::Send::Test; |
6 | use FindBin; |
7 | use lib "$FindBin::Bin/lib"; |
8 | |
8b10ee55 |
9 | eval "use Catalyst::View::TT"; |
10 | if ( $@ ) { |
11 | plan skip_all => 'Catalyst::View::TT required for Template tests'; |
12 | exit; |
13 | } |
ab4326b4 |
14 | plan tests => 11; |
8b10ee55 |
15 | |
82300460 |
16 | use_ok('Catalyst::Test', 'TestApp'); |
17 | |
18 | my $response; |
19 | my $time = time; |
20 | ok( ( $response = request("/template_email?time=$time"))->is_success, |
21 | 'request ok' ); |
22 | like( $response->content, qr/Template Email Ok/, 'controller says ok' ); |
23 | my @emails = Email::Send::Test->emails; |
24 | |
25 | cmp_ok(@emails, '==', 1, 'got emails'); |
26 | isa_ok( $emails[0], 'Email::MIME', 'email is ok' ); |
ab4326b4 |
27 | |
28 | like($emails[0]->content_type, qr#^multipart/alternative#, 'Multipart email'); |
29 | |
82300460 |
30 | my @parts = $emails[0]->parts; |
31 | cmp_ok(@parts, '==', 2, 'got parts'); |
32 | |
28151039 |
33 | is($parts[0]->content_type, 'text/plain', 'text/plain part ok'); |
fd0033bc |
34 | like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back'); |
43090696 |
35 | |
28151039 |
36 | is($parts[1]->content_type, 'text/html', 'text/html ok'); |
fd0033bc |
37 | like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back'); |
82300460 |
38 | #like($emails[0]->body, qr/$time/, 'Got our email'); |
39 | |