Bug 29395: use EXPORT_OK from Koha::Patron::Debarments

Missed from bug 17600.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-11-03 09:55:54 +01:00
parent 4f57531d14
commit 54fa48b139
8 changed files with 43 additions and 37 deletions

View File

@ -48,7 +48,7 @@ use Koha::Checkouts;
use Koha::Illrequests;
use Koha::Items;
use Koha::Patrons;
use Koha::Patron::Debarments qw( DelUniqueDebarment GetDebarments );
use Koha::Patron::Debarments qw( DelUniqueDebarment GetDebarments AddUniqueDebarment );
use Koha::Database;
use Koha::Libraries;
use Koha::Account::Lines;

View File

@ -21,19 +21,23 @@ use Modern::Perl;
use C4::Context;
use parent qw( Exporter );
our ( @ISA, @EXPORT_OK );
our @EXPORT = qw(
GetDebarments
BEGIN {
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = qw(
GetDebarments
AddDebarment
DelDebarment
ModDebarment
AddDebarment
DelDebarment
ModDebarment
AddUniqueDebarment
DelUniqueDebarment
AddUniqueDebarment
DelUniqueDebarment
);
);
}
=head1 Koha::Patron::Debarments

View File

@ -11,7 +11,7 @@ use C4::Letters qw( GetPreparedLetter );
use Koha::Database;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Patrons;
use Koha::Patron::Debarments;
use Koha::Patron::Debarments qw( AddDebarment );
sub count {
my ($params) = @_;

View File

@ -52,6 +52,7 @@ use Koha::Old::Patrons;
use Koha::Item::Transfers;
use Koha::PseudonymizedTransactions;
use Koha::Patron::Messages;
use Koha::Patron::Debarments qw( DelDebarment );
sub usage {
print STDERR <<USAGE;

View File

@ -46,6 +46,7 @@ use Koha::Items;
use Koha::Item::Transfers;
use Koha::Checkouts;
use Koha::Patrons;
use Koha::Patron::Debarments qw( GetDebarments AddDebarment DelUniqueDebarment );
use Koha::Holds;
use Koha::CirculationRules;
use Koha::Subscriptions;

View File

@ -30,7 +30,7 @@ use Koha::Database;
use Koha::DateUtils qw(dt_from_string);
use Koha::Old::Checkouts;
use Koha::Patrons;
use Koha::Patron::Debarments;
use Koha::Patron::Debarments qw( GetDebarments AddUniqueDebarment );
my $schema = Koha::Database->schema;
my $builder = t::lib::TestBuilder->new;

View File

@ -29,7 +29,7 @@ my $borrowernumber = Koha::Patron->new({
branchcode => $library->{branchcode},
})->store->borrowernumber;
my $success = AddDebarment({
my $success = Koha::Patron::Debarments::AddDebarment({
borrowernumber => $borrowernumber,
expiration => '9999-06-10',
type => 'MANUAL',
@ -38,31 +38,31 @@ my $success = AddDebarment({
is( $success, 1, "AddDebarment returned true" );
my $debarments = GetDebarments({ borrowernumber => $borrowernumber });
my $debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
is( @$debarments, 1, "GetDebarments returns 1 debarment" );
is( $debarments->[0]->{'type'}, 'MANUAL', "Correctly stored 'type'" );
is( $debarments->[0]->{'expiration'}, '9999-06-10', "Correctly stored 'expiration'" );
is( $debarments->[0]->{'comment'}, 'Test 1', "Correctly stored 'comment'" );
$success = AddDebarment({
$success = Koha::Patron::Debarments::AddDebarment({
borrowernumber => $borrowernumber,
comment => 'Test 2',
});
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
is( @$debarments, 2, "GetDebarments returns 2 debarments" );
is( $debarments->[1]->{'type'}, 'MANUAL', "Correctly stored 'type'" );
is( $debarments->[1]->{'expiration'}, undef, "Correctly stored debarrment with no expiration" );
is( $debarments->[1]->{'comment'}, 'Test 2', "Correctly stored 'comment'" );
ModDebarment({
Koha::Patron::Debarments::ModDebarment({
borrower_debarment_id => $debarments->[1]->{'borrower_debarment_id'},
comment => 'Test 3',
expiration => '9998-06-10',
});
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
is( $debarments->[1]->{'comment'}, 'Test 3', "ModDebarment functions correctly" );
my $patron = Koha::Patrons->find( $borrowernumber )->unblessed;
@ -70,23 +70,23 @@ is( $patron->{'debarred'}, '9999-06-10', "Field borrowers.debarred set correctly
is( $patron->{'debarredcomment'}, "Test 1\nTest 3", "Field borrowers.debarredcomment set correctly" );
AddUniqueDebarment({
Koha::Patron::Debarments::AddUniqueDebarment({
borrowernumber => $borrowernumber,
type => 'OVERDUES'
});
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( @$debarments, 1, "GetDebarments returns 1 OVERDUES debarment" );
is( $debarments->[0]->{'type'}, 'OVERDUES', "AddOverduesDebarment created new debarment correctly" );
AddUniqueDebarment({
Koha::Patron::Debarments::AddUniqueDebarment({
borrowernumber => $borrowernumber,
expiration => '9999-11-09',
type => 'OVERDUES'
});
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
@ -94,63 +94,63 @@ is( @$debarments, 1, "GetDebarments returns 1 OVERDUES debarment after running A
is( $debarments->[0]->{'expiration'}, '9999-11-09', "AddOverduesDebarment updated OVERDUES debarment correctly" );
my $delUniqueDebarment = DelUniqueDebarment({
my $delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
});
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the arguments 'borrowernumber' and 'type' returns undef" );
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( @$debarments, 1, "DelUniqueDebarment without the arguments 'borrowernumber' and 'type' does not delete the debarment" );
$delUniqueDebarment = DelUniqueDebarment({
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
borrowernumber => $borrowernumber,
});
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the argument 'type' returns undef" );
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( @$debarments, 1, "DelUniqueDebarment without the argument 'type' does not delete the debarment" );
$delUniqueDebarment = DelUniqueDebarment({
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
type => 'OVERDUES'
});
is( $delUniqueDebarment, undef, "DelUniqueDebarment without the argument 'borrowernumber' returns undef" );
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( @$debarments, 1, "DelUniqueDebarment without the argument 'borrowerumber' does not delete the debarment" );
$delUniqueDebarment = DelUniqueDebarment({
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
borrowernumber => $borrowernumber,
type => 'SUSPENSION',
});
is( $delUniqueDebarment, undef, "DelUniqueDebarment with wrong arguments returns undef" );
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( @$debarments, 1, "DelUniqueDebarment with wrong arguments does not delete the debarment" );
$delUniqueDebarment = DelUniqueDebarment({
$delUniqueDebarment = Koha::Patron::Debarments::DelUniqueDebarment({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( $delUniqueDebarment, 1, "DelUniqueDebarment returns 1" );
$debarments = GetDebarments({
$debarments = Koha::Patron::Debarments::GetDebarments({
borrowernumber => $borrowernumber,
type => 'OVERDUES',
});
is( @$debarments, 0, "DelUniqueDebarment functions correctly" );
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
foreach my $d ( @$debarments ) {
DelDebarment( $d->{'borrower_debarment_id'} );
Koha::Patron::Debarments::DelDebarment( $d->{'borrower_debarment_id'} );
}
$debarments = GetDebarments({ borrowernumber => $borrowernumber });
$debarments = Koha::Patron::Debarments::GetDebarments({ borrowernumber => $borrowernumber });
is( @$debarments, 0, "DelDebarment functions correctly" );
$dbh->do(q|UPDATE borrowers SET debarred = '1970-01-01'|);
@ -173,7 +173,7 @@ my $borrowernumber2 = Koha::Patron->new(
)->store->borrowernumber;
my $debarreddate2 = '9999-06-10'; # Be sure to be in the future
my $debarredcomment2 = 'Test merge';
AddDebarment(
Koha::Patron::Debarments::AddDebarment(
{
borrowernumber => $borrowernumber2,
expiration => $debarreddate2,

View File

@ -32,7 +32,7 @@ use Koha::DateUtils qw(dt_from_string output_pref);
use Koha::Exceptions::Patron;
use Koha::Exceptions::Patron::Attribute;
use Koha::Patron::Attributes;
use Koha::Patron::Debarments qw/AddDebarment/;
use Koha::Patron::Debarments qw( AddDebarment );
use JSON qw(encode_json);