Bug 29046: Unit tests

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Martin Renvoize 2023-04-20 14:18:20 +01:00 committed by Tomas Cohen Arazi
parent c731680b5d
commit 2a9c6db338
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 28 additions and 16 deletions

View file

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 22;
use Test::More tests => 24;
use Test::Exception;
use Test::Warn;
@ -1393,6 +1393,32 @@ subtest 'notify_library_of_registration()' => sub {
$schema->storage->txn_rollback;
};
subtest 'notice_email_address' => sub {
plan tests => 2;
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
t::lib::Mocks::mock_preference( 'EmailFieldPrecedence', 'email|emailpro' );
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' );
is ($patron->notice_email_address, $patron->email, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is off");
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' );
is ($patron->notice_email_address, $patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro");
$patron->delete;
};
subtest 'first_valid_email_address' => sub {
plan tests => 1;
my $patron = $builder->build_object({ class => 'Koha::Patrons', value => { emailpro => ''}});
t::lib::Mocks::mock_preference( 'EmailFieldPrecedence', 'emailpro|email' );
is ($patron->first_valid_email_address, $patron->email, "Koha::Patron->first_valid_email_address returns correct value when EmailFieldPrecedence is 'emailpro|email' and emailpro is empty");
$patron->delete;
};
subtest 'get_savings tests' => sub {
plan tests => 4;

View file

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 44;
use Test::More tests => 43;
use Test::Warn;
use Test::Exception;
use Test::MockModule;
@ -1061,20 +1061,6 @@ subtest 'holds and old_holds' => sub {
$patron->delete;
};
subtest 'notice_email_address' => sub {
plan tests => 2;
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' );
is ($patron->notice_email_address, $patron->email, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is off");
t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'emailpro' );
is ($patron->notice_email_address, $patron->emailpro, "Koha::Patron->notice_email_address returns correct value when EmailFieldPrimary is emailpro");
$patron->delete;
};
subtest 'search_patrons_to_anonymise' => sub {
plan tests => 5;