From 2666f34b0ce8ebf3451b1f9c7436dafb46092912 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 --- 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 6373c0e647..705bd7f68a 100755 --- a/t/db_dependent/Reports/Guided.t +++ b/t/db_dependent/Reports/Guided.t @@ -365,7 +365,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 }; @@ -379,7 +379,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({ @@ -387,7 +388,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 } }); @@ -416,12 +428,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