Commit | Line | Data |
8b10ee55 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
cce24d41 |
4 | BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' } |
8b10ee55 |
5 | use FindBin; |
6 | use lib "$FindBin::Bin/lib"; |
7 | |
cce24d41 |
8 | use Email::Sender::Simple; |
9 | |
8b10ee55 |
10 | eval "use Catalyst::View::Mason"; |
11 | if ( $@ ) { |
12 | plan skip_all => 'Catalyst::View::Mason required for Mason tests'; |
13 | exit; |
14 | } |
8b10ee55 |
15 | |
16 | use_ok('Catalyst::Test', 'TestApp'); |
17 | |
c649c40e |
18 | TestApp->config->{default_view} = 'Mason'; |
cce24d41 |
19 | use Data::Dumper; |
8b10ee55 |
20 | my $response; |
21 | my $time = time; |
22 | ok( ( $response = request("/mason_email?time=$time"))->is_success, |
23 | 'request ok' ); |
24 | like( $response->content, qr/Mason Email Ok/, 'controller says ok' ); |
cce24d41 |
25 | my @emails = Email::Sender::Simple->default_transport->deliveries; |
1e331578 |
26 | #warn "Email: " . Dumper @emails; |
8b10ee55 |
27 | cmp_ok(@emails, '==', 1, 'got emails'); |
cce24d41 |
28 | isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' ); |
29 | my @parts = $emails[0]->{'email'}[0]->parts; |
8b10ee55 |
30 | cmp_ok(@parts, '==', 2, 'got parts'); |
1e331578 |
31 | #warn "Parts: " . Dumper @parts; |
28151039 |
32 | is($parts[0]->content_type, 'text/plain', 'text/plain ok'); |
8b10ee55 |
33 | like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back'); |
28151039 |
34 | is($parts[1]->content_type, 'text/html', 'text/html ok'); |
8b10ee55 |
35 | like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back'); |
36 | #like($emails[0]->body, qr/$time/, 'Got our email'); |
cce24d41 |
37 | done_testing(); |