1Test::Email(3)        User Contributed Perl Documentation       Test::Email(3)
2
3
4

NAME

6       Test::Email - Test Email Contents
7

SYNOPSIS

9         use Test::Email;
10
11         # is-a MIME::Entity
12         my $email = Test::Email->new(\@lines);
13
14         # all-in-one test
15         $email->ok({
16           # optional search parameters
17           from       => ($is or qr/$regex/),
18           subject    => ($is or qr/$regex/),
19           body       => ($is or qr/$regex/),
20           headername => ($is or qr/$regex/),
21         }, "passed tests");
22
23         # single-test header methods
24         $email->header_is($header_name, $value, "$header_name matches");
25         $email->header_ok($header_name, $value, "$header_name matches");
26         $email->header_like($header_name, qr/regex/, "$header_name matches");
27
28         # single-test body methods
29         $email->body_is($header_name, $value, "$header_name matches");
30         $email->body_ok($header_name, $value, "$header_name matches");
31         $email->body_like($header_name, qr/regex/, "$header_name matches");
32

DESCRIPTION

34       Please note that this is ALPHA CODE. As such, the interface is likely
35       to change.
36
37       Test::Email is a subclass of MIME::Entity, with the above methods.  If
38       you want the messages fetched from a POP3 account, use Test::POP3.
39
40       Tests for equality remove trailing newlines from strings before
41       testing.  This is because some mail messages have newlines appended to
42       them during the mailing process, which could cause unnecessary
43       confusion.
44
45       This module should be 100% self-explanatory. If not, then please look
46       at Test::Simple and Test::More for clarification.
47
48       This module does not yet test MIME, but it will soon.
49

METHODS

51       "my $email = Test::Email->new($lines_aref);"
52           This is identical to "MIME::Entity->new()". See there for details.
53
54       "$email->ok($test_href, $description);"
55           Using this method, you can test multiple qualities of an email
56           message with one test. This will execute the tests as expected and
57           will produce output just like "Test::Simple::ok" and
58           "Test::More::ok". Keys for $test_href are either "body", or they
59           are considered to be the name of a header, case-insensitive.
60
61       single-test methods
62           The single-test methods in the synopsis above are very similar to
63           their counterparts in Test::Simple and Test::More. Please consult
64           those modules for documentation.
65
66           Please note that tests for equality remove newlines from their
67           operands before testing. This is because some email messages have
68           newlines appended to them during mailing.
69

EXPORT

71       None.
72

SEE ALSO

74       Test::Builder, Test::Simple, Test::More, Test::POP3
75

TODO

77       Much. This is only a first step.
78

AUTHOR

80       James Tolley, <james@cpan.org>
81
83       Copyright (C) 2007 by James Tolley
84
85       This library is free software; you can redistribute it and/or modify it
86       under the same terms as Perl itself, either Perl version 5.8.8 or, at
87       your option, any later version of Perl 5 you may have available.
88
89
90
91perl v5.12.0                      2007-06-09                    Test::Email(3)
Impressum