File: 07mason.t

package info (click to toggle)
libcatalyst-view-email-perl 0.36-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 308 kB
  • sloc: perl: 2,665; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 1,112 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use strict;
use warnings;
use Test::More;
use Test::Requires {
    'Catalyst::View::Mason' => '0.18',
};

##
BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test' }
use FindBin;
use lib "$FindBin::Bin/lib";

use Email::Sender::Simple;

use_ok('Catalyst::Test', 'TestApp');

TestApp->config->{default_view} = 'Mason';
my $response;
my $time = time;
ok( ( $response = request("/mason_email?time=$time"))->is_success,
    'request ok' );
like( $response->content, qr/Mason Email Ok/, 'controller says ok' );
my @emails = Email::Sender::Simple->default_transport->deliveries;
cmp_ok(@emails, '==', 1, 'got emails');
isa_ok( $emails[0]->{'email'}, 'Email::Abstract', 'email is ok' );
my @parts = $emails[0]->{'email'}[0]->parts;
cmp_ok(@parts, '==', 2, 'got parts');
is($parts[0]->content_type, 'text/plain', 'text/plain ok');
like($parts[0]->body, qr/test-email\@example.com on $time/, 'got content back');
is($parts[1]->content_type, 'text/html', 'text/html ok');
like($parts[1]->body, qr{<em>test-email\@example.com</em> on $time}, 'got content back');
#like($emails[0]->body, qr/$time/, 'Got our email');
done_testing();