From cfb54d318d11da5c77482a530ccf46b077c26229 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 3 Feb 2021 10:16:30 +0000 Subject: [PATCH] Bug 27600: Add unit test This patch adds a basic unit test to catch the case where patron_pwd is sent to renew_all as an empty string. Test plan 1/ Run t/db_dependent/SIP/ILS.t and watch it fail 2/ Apply second patch 3/ Re-run the above test and watch it pass. --- t/db_dependent/SIP/ILS.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/SIP/ILS.t b/t/db_dependent/SIP/ILS.t index 99c0df2147..f39fb28b11 100755 --- a/t/db_dependent/SIP/ILS.t +++ b/t/db_dependent/SIP/ILS.t @@ -20,7 +20,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 12; use t::lib::TestBuilder; use t::lib::Mocks; @@ -174,4 +174,25 @@ subtest checkout => sub { is( $checkout->renewals, 1, "Renewals has been reduced"); }; +subtest renew_all => sub { + plan tests => 1; + + my $library = $builder->build_object ({ class => 'Koha::Libraries' }); + my $patron = $builder->build_object( + { + class => 'Koha::Patrons', + value => { + branchcode => $library->branchcode, + } + } + ); + t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode, flags => 1 }); + + my $ils = C4::SIP::ILS->new({ id => $library->branchcode }); + + # Send empty AD segments (i.e. empty string for patron_pwd) + my $transaction = $ils->renew_all( $patron->cardnumber, "", undef ); + isnt( $transaction->{screen_msg}, 'Invalid patron password.', "Empty password succeeds" ); +}; + $schema->storage->txn_rollback; -- 2.20.1