root/branches/new-install-process/t/77_send_email.t

Revision 1104, 1.2 kB (checked in by dom, 18 months ago)

Small cleanups prior to release

Line 
1use strict;
2use OpenGuides::Config;
3use OpenGuides::Utils;
4use Test::More;
5
6plan tests => 6;
7
8my $config = OpenGuides::Config->new(
9    vars => {
10        contact_email => 'admin@example.com'
11    }
12);
13
14my $output = OpenGuides::Utils->send_email(
15    config        => $config,
16    return_output => 1,
17    to            => [ 'user@example.com' ],
18    subject       => 'Test subject',
19    body          => 'Test body'
20);
21
22like( $output, qr|^From: admin\@example\.com|m, "From address shown" );
23like( $output, qr|^To: user\@example\.com|m, "To address shown correctly" );
24like( $output, qr|^Subject: Test subject|m, "Subject shown correctly" );
25like( $output, qr|^Test body|m, "Body text appears at the start of a line" );
26
27$output = OpenGuides::Utils->send_email(
28    config        => $config,
29    return_output => 1,
30    admin         => 1,
31    subject       => 'Test subject',
32    body          => 'Test body'
33);
34
35like( $output, qr|^To: admin\@example\.com|m, "Admin address used ".
36    "appropriately" );
37
38eval { $output = OpenGuides::Utils->send_email(
39    config        => $config,
40    return_output => 1,
41    subject       => 'Test subject',
42    body          => 'Test body'
43); };
44
45like( $@, qr|No recipients specified|, "No recipients error caught" );
Note: See TracBrowser for help on using the browser.