-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #25: mixed + alternative not supported
- Loading branch information
1 parent
0f3d7e6
commit c58a0f9
Showing
3 changed files
with
93 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ use warnings; | |
use Test::More qw[no_plan]; | ||
use Email::Stuffer; | ||
use Email::Sender::Transport::Test (); | ||
use File::Spec::Functions ':ALL'; | ||
|
||
my $TEST_GIF = catfile( 't', 'data', 'paypal.gif' ); | ||
ok( -f $TEST_GIF, "Found test image: $TEST_GIF" ); | ||
|
||
##################################################################### | ||
# Multipart/Alternate tests | ||
|
@@ -34,4 +37,35 @@ my $mime = $email->object; | |
like( ($mime->subparts)[0]->body_str, qr/I am an emáil/, 'Email contains text_body' ); | ||
like( ($mime->subparts)[1]->body_str, qr/<b>I am a html emáil<\/b>/, 'Email contains text_body' ); | ||
|
||
##################################################################### | ||
# Multipart/Alternate tests with attachment | ||
|
||
my $rv2 = Email::Stuffer->from ( 'Adam Kennedy<[email protected]>') | ||
->to ( '[email protected]' ) | ||
->subject ( 'Hello To:!' ) | ||
->text_body ( 'I am an emáil' ) | ||
->html_body ( '<b>I am a html emáil</b>' ) | ||
->attach_file( $TEST_GIF ) | ||
->transport ( $test ) | ||
->send; | ||
ok( $rv2, 'Email sent ok' ); | ||
is( $test->delivery_count, 1, 'Sent one email' ); | ||
$email = $test->shift_deliveries->{email}; | ||
$string = $email->as_string; | ||
|
||
like( $string, qr/Adam Kennedy/, 'Email contains from name' ); | ||
like( $string, qr/phase-n/, 'Email contains to string' ); | ||
like( $string, qr/Hello/, 'Email contains subject string' ); | ||
like( $string, qr/Content-Type: multipart\/alternative/, 'Email content type' ); | ||
like( $string, qr/Content-Type: text\/plain/, 'Email content type' ); | ||
like( $string, qr/Content-Type: text\/html/, 'Email content type' ); | ||
|
||
$mime = $email->object; | ||
like( (($mime->subparts)[0]->subparts)[0]->body_str, qr/I am an emáil/, 'Email contains text_body' ); | ||
like( (($mime->subparts)[0]->subparts)[1]->body_str, qr/<b>I am a html emáil<\/b>/, 'Email contains text_body' ); | ||
like( ($mime->subparts)[0]->content_type, qr{^multipart/alternative}, 'First part is multipart/alternative'); | ||
like( ($mime->subparts)[1]->content_type, qr{^image/gif}, 'Second part is image/gif'); | ||
like( (($mime->subparts)[0]->subparts)[0]->content_type, qr{text/plain}, 'First text sub part is text/plain' ); | ||
like( (($mime->subparts)[0]->subparts)[1]->content_type, qr{text/html}, 'Second text sub part is text/html' ); | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,12 +115,17 @@ my $rv2 = Email::Stuffer->from ( 'Adam Kennedy<[email protected]>') | |
->send; | ||
ok( $rv2, 'Email sent ok' ); | ||
is( $test->delivery_count, 1, 'Sent one email' ); | ||
my $email = $test->shift_deliveries->{email}->as_string; | ||
like( $email, qr/Adam Kennedy/, 'Email contains from name' ); | ||
like( $email, qr/phase-n/, 'Email contains to string' ); | ||
like( $email, qr/Hello/, 'Email contains subject string' ); | ||
like( $email, qr/I am an email/, 'Email contains text_body' ); | ||
like( $email, qr/paypal/, 'Email contains file name' ); | ||
my $email = $test->shift_deliveries->{email}; | ||
my $string = $email->as_string; | ||
like( $string, qr/Adam Kennedy/, 'Email contains from name' ); | ||
like( $string, qr/phase-n/, 'Email contains to string' ); | ||
like( $string, qr/Hello/, 'Email contains subject string' ); | ||
like( $string, qr/I am an email/, 'Email contains text_body' ); | ||
like( $string, qr/paypal/, 'Email contains file name' ); | ||
|
||
my $mime = $email->object; | ||
like( ($mime->subparts)[0]->content_type, qr{^text/plain}, 'First part is text/plain'); | ||
like( ($mime->subparts)[1]->content_type, qr{^image/gif}, 'Second part is image/gif'); | ||
|
||
# attach_file content_type | ||
$rv2 = Email::Stuffer->from ( 'Adam Kennedy<[email protected]>' ) | ||
|