From 7130f7d4eda4a1faca18657df6cde62c779fe3c7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 19 Oct 2021 16:57:10 +0100 Subject: [PATCH] Bug 28729: Unit tests Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- t/Koha/Email.t | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/t/Koha/Email.t b/t/Koha/Email.t index a329950a37..0d12016725 100755 --- a/t/Koha/Email.t +++ b/t/Koha/Email.t @@ -191,7 +191,7 @@ subtest 'create() tests' => sub { subtest 'send_or_die() tests' => sub { - plan tests => 4; + plan tests => 7; my $email; my $args; @@ -232,9 +232,10 @@ subtest 'send_or_die() tests' => sub { ); $THE_email->send_or_die( - { transport => $transport, to => ['tomasito@mail.com'] } ); + { transport => $transport, to => ['tomasito@mail.com'], from => 'returns@example.com' } ); is_deeply( $args->{to}, ['tomasito@mail.com'], 'If explicitly passed, "to" is preserved' ); + is( $args->{from}, 'returns@example.com', 'If explicitly pass, "from" is preserved'); $THE_email->send_or_die( { transport => $transport } ); my @to = sort @{ $args->{to} }; @@ -247,6 +248,9 @@ subtest 'send_or_die() tests' => sub { 'If "to" is not explicitly passed, extract recipients from headers' ); is( $email->header_str('Bcc'), undef, 'The Bcc header is unset' ); + my $from = $args->{from}; + is( $from, 'sender@example.com', 'If "from" is not explicitly passed, extract from Sender header' ); + is( $email->header_str('Sender'), undef, 'The Sender header is unset' ); }; subtest 'is_valid' => sub { -- 2.39.5