aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand/zurich.t
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-03-15 13:29:42 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2016-03-23 08:56:06 +0000
commitcb49284dc0503b2a05ca2bb98b8a1320431c2616 (patch)
treebe4ddb1fc16cf45b67e3cf0683506a493de4b27e /t/cobrand/zurich.t
parentd3d0ab6d5a753d1e5c8277db981f03823683ae1f (diff)
Updates to cpanfile and code for perl 5.20/5.22.
The following modules had bugs that have been fixed for working in recent perls: * List::MoreUtils * Guard * PadWalker * aliased * URI * Convert::NLS_DATE_FORMAT The CGI module was removed from core in 5.20, so include it in the snapshot (I don't think it's actually used, but is a dependency). "{" needs to be escaped in regular expressions, and ~~ should not be used. Fix some tests that expect e.g. a certain hash ordering, to use sorted output or better comparisons.
Diffstat (limited to 't/cobrand/zurich.t')
-rw-r--r--t/cobrand/zurich.t18
1 files changed, 15 insertions, 3 deletions
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 777e9735f..e130ece87 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -4,6 +4,7 @@
use strict;
use warnings;
use DateTime;
+use Email::MIME;
use Test::More;
use Test::LongString;
use Path::Tiny;
@@ -884,15 +885,26 @@ subtest 'email images to external partners' => sub {
my @emails = $mech->get_email;
my $email_as_string = $mech->get_first_email(@emails);
my ($boundary) = $email_as_string =~ /boundary="([A-Za-z0-9.]*)"/ms;
- my $changes = $email_as_string =~ s{$boundary}{}g;
- is $changes, 4, '4 boundaries'; # header + 3 around the 2x parts (text + 1 image)
+ my $email = Email::MIME->new($email_as_string);
my $expected_email_content = path(__FILE__)->parent->child('zurich_attachments.txt')->slurp;
my $REPORT_ID = $report->id;
$expected_email_content =~ s{REPORT_ID}{$REPORT_ID}g;
+ $expected_email_content =~ s{BOUNDARY}{$boundary}g;
+ my $expected_email = Email::MIME->new($expected_email_content);
- is_string $email_as_string, $expected_email_content, 'MIME email text ok'
+ my @email_parts;
+ $email->walk_parts(sub {
+ my ($part) = @_;
+ push @email_parts, [ { $part->header_pairs }, $part->body ];
+ });
+ my @expected_email_parts;
+ $expected_email->walk_parts(sub {
+ my ($part) = @_;
+ push @expected_email_parts, [ { $part->header_pairs }, $part->body ];
+ });
+ is_deeply \@email_parts, \@expected_email_parts, 'MIME email text ok'
or do {
(my $test_name = $0) =~ s{/}{_}g;
my $path = path("test-output-$test_name.tmp");