.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::Email 3pm" .TH Test::Email 3pm "2015-12-25" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::Email \- Test Email Contents .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Test::Email; \& \& # is\-a MIME::Entity \& my $email = Test::Email\->new(\e@lines); \& \& # all\-in\-one test \& $email\->ok({ \& # optional search parameters \& from => ($is or qr/$regex/), \& subject => ($is or qr/$regex/), \& body => ($is or qr/$regex/), \& headername => ($is or qr/$regex/), \& }, "passed tests"); \& \& # single\-test header methods \& $email\->header_is($header_name, $value, "$header_name matches"); \& $email\->header_ok($header_name, $value, "$header_name matches"); \& $email\->header_like($header_name, qr/regex/, "$header_name matches"); \& \& # single\-test body methods \& $email\->body_is($header_name, $value, "$header_name matches"); \& $email\->body_ok($header_name, $value, "$header_name matches"); \& $email\->body_like($header_name, qr/regex/, "$header_name matches"); \& \& # how many MIME parts does the messages contain? \& $email\->parts_ok($parts_count, "there were $parts_count parts found"); \& \& # what is the MIME type of the firs part \& my @parts = $email\->parts(); # see MIME::Entity \& $parts[0]\->mime_type_ok(\*(Aqtest/html\*(Aq, \*(Aqthe first part is type text/html\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Please note that this is \s-1ALPHA CODE.\s0 As such, the interface is likely to change. .PP Test::Email is a subclass of MIME::Entity, with the above methods. If you want the messages fetched from a \s-1POP3\s0 account, use Test::POP3. .PP Tests for equality remove trailing newlines from strings before testing. This is because some mail messages have newlines appended to them during the mailing process, which could cause unnecessary confusion. .PP This module should be 100% self-explanatory. If not, then please look at Test::Simple and Test::More for clarification. .SH "METHODS" .IX Header "METHODS" .ie n .IP """my $email = Test::Email\->new($lines_aref);""" 4 .el .IP "\f(CWmy $email = Test::Email\->new($lines_aref);\fR" 4 .IX Item "my $email = Test::Email->new($lines_aref);" This is identical to \f(CW\*(C`MIME::Entity\->new()\*(C'\fR. See there for details. .ie n .IP """$email\->ok($test_href, $description);""" 4 .el .IP "\f(CW$email\->ok($test_href, $description);\fR" 4 .IX Item "$email->ok($test_href, $description);" Using this method, you can test multiple qualities of an email message with one test. This will execute the tests as expected and will produce output just like \f(CW\*(C`Test::Simple::ok\*(C'\fR and \f(CW\*(C`Test::More::ok\*(C'\fR. Keys for \&\f(CW$test_href\fR are either \f(CW\*(C`body\*(C'\fR, or they are considered to be the name of a header, case-insensitive. .IP "single-test methods" 4 .IX Item "single-test methods" The single-test methods in the synopsis above are very similar to their counterparts in Test::Simple and Test::More. Please consult those modules for documentation. .Sp Please note that tests for equality remove newlines from their operands before testing. This is because some email messages have newlines appended to them during mailing. .ie n .IP """my $ok = $email\-""parts_ok($parts_count, $description);>" 4 .el .IP "\f(CWmy $ok = $email\-\fRparts_ok($parts_count, \f(CW$description\fR);>" 4 .IX Item "my $ok = $email-parts_ok($parts_count, $description);>" Check to see how many \s-1MIME\s0 parts this email contains. Each part is also a Test::Email object. .ie n .IP """my $ok = $email\-""mime_type_ok($expected_mime_type, $description);>" 4 .el .IP "\f(CWmy $ok = $email\-\fRmime_type_ok($expected_mime_type, \f(CW$description\fR);>" 4 .IX Item "my $ok = $email-mime_type_ok($expected_mime_type, $description);>" Check the \s-1MIME\s0 type of an email or an email part. .SH "EXPORT" .IX Header "EXPORT" None. .SH "SEE ALSO" .IX Header "SEE ALSO" Test::Builder, Test::Simple, Test::More, Test::POP3 .SH "TODO" .IX Header "TODO" I am open to suggestions. .SH "AUTHOR" .IX Header "AUTHOR" James Tolley, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2007\-2008 by James Tolley .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.