From 8407c793781424eeb0657ec6f2fc230fbe1f70db Mon Sep 17 00:00:00 2001 From: David Gustafsson Date: Wed, 15 Sep 2021 15:32:35 +0200 Subject: [PATCH] Bug 27884: Add tests Signed-off-by: David Nind Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit cd5c1be348f75b3f7a38d0bcaf5757153d7d1e88) Signed-off-by: Fridolin Somers --- t/db_dependent/Reports/Guided.t | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Reports/Guided.t b/t/db_dependent/Reports/Guided.t index 4352d48568..2d3977a03e 100755 --- a/t/db_dependent/Reports/Guided.t +++ b/t/db_dependent/Reports/Guided.t @@ -364,7 +364,7 @@ count(h.reservedate) AS 'holds' subtest 'Email report test' => sub { - plan tests => 12; + plan tests => 14; my $dbh = C4::Context->dbh; my $id1 = $builder->build({ source => 'Borrower',value => { surname => 'mailer', email => 'a@b.com', emailpro => 'b@c.com' } })->{ borrowernumber }; @@ -378,7 +378,8 @@ subtest 'Email report test' => sub { value => { content => "[% surname %]", branchcode => "", - message_transport_type => 'email' + message_transport_type => 'email', + is_html => undef } }); my $letter2 = $builder->build({ @@ -386,7 +387,18 @@ subtest 'Email report test' => sub { value => { content => "[% firstname %]", branchcode => "", - message_transport_type => 'email' + message_transport_type => 'email', + is_html => 0 + } + }); + + my $letter3 = $builder->build({ + source => 'Letter', + value => { + content => "[% surname %]", + branchcode => "", + message_transport_type => 'email', + is_html => 1 } }); @@ -415,12 +427,16 @@ subtest 'Email report test' => sub { ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module} , code => $letter1->{code}, from => 'the@future.ooh' }); is( $emails->[0]{letter}->{content}, "mailer", "Message has expected content"); is( $emails->[1]{letter}->{content}, "norman", "Message has expected content"); + is( $emails->[0]{letter}->{'content-type'}, undef, "Message content type is not set for plain text mail"); ($emails, $errors ) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter1->{module} , code => $letter1->{code}, from => 'the@future.ooh', email => 'emailpro' }); is_deeply( $errors, [{'NO_EMAIL_COL'=>3}],"We report missing email in emailpro column"); is( $emails->[0]->{to_address}, 'b@c.com', "Message uses correct email"); is( $emails->[1]->{to_address}, 'd@e.com', "Message uses correct email"); + ($emails) = C4::Reports::Guided::EmailReport({report_id => $report1, module => $letter3->{module} , code => $letter3->{code}, from => 'the@future.ooh' }); + is( $emails->[0]{letter}->{'content-type'}, 'text/html; charset="UTF-8"', "Message has expected content type"); + }; $schema->storage->txn_rollback; -- 2.39.5