|
Revision 1104, 1.2 kB
(checked in by dom, 17 months ago)
|
|
Small cleanups prior to release
|
| Line | |
|---|
| 1 | use strict; |
|---|
| 2 | use OpenGuides::Config; |
|---|
| 3 | use OpenGuides::Utils; |
|---|
| 4 | use Test::More; |
|---|
| 5 | |
|---|
| 6 | plan tests => 6; |
|---|
| 7 | |
|---|
| 8 | my $config = OpenGuides::Config->new( |
|---|
| 9 | vars => { |
|---|
| 10 | contact_email => 'admin@example.com' |
|---|
| 11 | } |
|---|
| 12 | ); |
|---|
| 13 | |
|---|
| 14 | my $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 | |
|---|
| 22 | like( $output, qr|^From: admin\@example\.com|m, "From address shown" ); |
|---|
| 23 | like( $output, qr|^To: user\@example\.com|m, "To address shown correctly" ); |
|---|
| 24 | like( $output, qr|^Subject: Test subject|m, "Subject shown correctly" ); |
|---|
| 25 | like( $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 | |
|---|
| 35 | like( $output, qr|^To: admin\@example\.com|m, "Admin address used ". |
|---|
| 36 | "appropriately" ); |
|---|
| 37 | |
|---|
| 38 | eval { $output = OpenGuides::Utils->send_email( |
|---|
| 39 | config => $config, |
|---|
| 40 | return_output => 1, |
|---|
| 41 | subject => 'Test subject', |
|---|
| 42 | body => 'Test body' |
|---|
| 43 | ); }; |
|---|
| 44 | |
|---|
| 45 | like( $@, qr|No recipients specified|, "No recipients error caught" ); |
|---|