| 1 | package Eve::EmailStub; | ||
| 2 | |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 2 | ▶ | use vars qw(%ENV); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 2 | ▶ | BEGIN { $ENV{EMAIL_SENDER_TRANSPORT} = 'Test'; } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 2 | ▶ | use Eve::Email; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | B<Eve::EmailStub> - a helper stub class that replaces the mailer class. | ||
| 15 | |||
| 16 | =head1 SYNOPSIS | ||
| 17 | |||
| 18 | package SomeTestCase; | ||
| 19 | |||
| 20 | use Eve::EmailStub; | ||
| 21 | use Eve::Email; | ||
| 22 | |||
| 23 | my $already_mocked_email = Eve::Email->new(from => $from_string); | ||
| 24 | |||
| 25 | $already_mocked_email->send( | ||
| 26 | to => $address, | ||
| 27 | subject => $subject, | ||
| 28 | body => $body); | ||
| 29 | |||
| 30 | my $delivery = $already_mocked_email->get_delivery(); | ||
| 31 | |||
| 32 | is( | ||
| 33 | $delivery->{'envelope'}->{'to'}->[0], | ||
| 34 | $address); | ||
| 35 | |||
| 36 | =head1 DESCRIPTION | ||
| 37 | |||
| 38 | B<Eve::EmailStub> is the class that uses the B<Email::Simple> class' | ||
| 39 | internal testing feature to replace the sender's engine with a test engine. | ||
| 40 | |||
| 41 | =head1 METHODS | ||
| 42 | |||
| 43 | =head2 B<get_delivery()> | ||
| 44 | |||
| 45 | Returns testing information about a last sent message. | ||
| 46 | |||
| 47 | =cut | ||
| 48 | |||
| 49 | 2 | ▶ | sub get_delivery { |
|
Subroutine
get_delivery: called CC=1 SCAR=0.0
Pod
documented
| |||
| 50 | 2 | my @deliveries = Email::Sender::Simple->default_transport->deliveries(); | |
| 51 | |||
| 52 | 2 | return $deliveries[$#deliveries]; | |
| 53 | } | ||
| 54 | |||
| 55 | =head1 SEE ALSO | ||
| 56 | |||
| 57 | =over 4 | ||
| 58 | |||
| 59 | =item L<Eve::Test> | ||
| 60 | |||
| 61 | =item L<Email::Simple> | ||
| 62 | |||
| 63 | =item L<Test::Class> | ||
| 64 | |||
| 65 | =back | ||
| 66 | |||
| 67 | =head1 LICENSE AND COPYRIGHT | ||
| 68 | |||
| 69 | Copyright 2010-2013 Sergey Konoplev, Igor Zinovyev. | ||
| 70 | |||
| 71 | This program is free software; you can redistribute it and/or modify it | ||
| 72 | under the terms of either: the GNU General Public License as published | ||
| 73 | by the Free Software Foundation; or the Artistic License. | ||
| 74 | |||
| 75 | See http://dev.perl.org/licenses/ for more information. | ||
| 76 | |||
| 77 | =head1 AUTHOR | ||
| 78 | |||
| 79 | =over 4 | ||
| 80 | |||
| 81 | =item L<Sergey Konoplev|mailto:gray.ru@gmail.com> | ||
| 82 | |||
| 83 | =item L<Igor Zinovyev|mailto:zinigor@gmail.com> | ||
| 84 | |||
| 85 | =back | ||
| 86 | |||
| 87 | =cut | ||
| 88 | |||
| 89 | 2 | 1; | |