Debian Codegraph @

t/.svn/text-base/03_headers.t.svn-base

raw
1 #!perl
2 use strict;
3 use warnings FATAL => 'all';
4
5 use Data::Dumper;
6 use Mail::Sendmail;
7 use Test::More tests => 7;
8 BEGIN { use_ok('Test::POP3') };
9
10 #########################
11
12 my ($host, $user, $pass, $smtp, $email) = get_info();
13
14 # don't surprise/confuse the user
15 # we expect to fail some of these
16 $Test::Email::QUIET_DIAG = 1;
17
18 SKIP: {
19 skip 'No POP3 settings found', 5 unless $host;
20 my $pop3 = Test::POP3->new({
21 host => $host,
22 user => $user,
23 pass => $pass,
24 });
25
26 # no tmpfiles
27 my $parser = $pop3->get_parser();
28 $parser->output_to_core(1);
29
30 # no messages
31 $pop3->delete_all();
32 my $msg_count = $pop3->get_email_count(1);
33 is($msg_count, 0, 'no messages');
34
35 # send 3 messages
36 sendmail(
37 to => $email,
38 from => $email,
39 subject => 'test 1',
40 message => 'message 1',
41 smtp => $smtp,
42 );
43 sleep 1;
44 sendmail(
45 to => $email,
46 from => $email,
47 subject => 'test 2',
48 message => 'message 2',
49 smtp => $smtp,
50 );
51 sleep 1;
52 sendmail(
53 to => $email,
54 from => $email,
55 subject => 'test 3',
56 message => 'message 3',
57 smtp => $smtp,
58 );
59
60 # then wait for them
61 is($pop3->wait_for_email_count(3), 3, 'found 3 messages');
62
63 $pop3->ok({
64 subject => qr/ 1$/,
65 }, 'subject regexp');
66
67 $pop3->ok({
68 subject => 'test 2',
69 }, 'subject string');
70
71 $pop3->ok({
72 subject => 'test 3',
73 'content-type' => qr|text/plain|,
74 }, 'subject and content-type');
75
76 is($pop3->delete_all(), 0, 'no others to be deleted');
77 };
78
79 sub get_info {
80 return map $ENV{"TEST_POP3_$_"}, map uc, qw(host user pass smtp email);
81 }
82
83 __END__
84