Bugzilla – Attachment 127230 Details for
Bug 29395
Use EXPORT_OK in Koha::Patron::Debarments
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29395: use EXPORT_OK from Koha::Patron::Debarments
Bug-29395-use-EXPORTOK-from-KohaPatronDebarments.patch (text/plain), 11.12 KB, created by
Jonathan Druart
on 2021-11-03 09:05:05 UTC
(
hide
)
Description:
Bug 29395: use EXPORT_OK from Koha::Patron::Debarments
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-11-03 09:05:05 UTC
Size:
11.12 KB
patch
obsolete
>From 0a960e2cffe9380df15f542ef844e62750157b6c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 3 Nov 2021 09:55:54 +0100 >Subject: [PATCH] Bug 29395: use EXPORT_OK from Koha::Patron::Debarments > >Missed from bug 17600. >--- > C4/Circulation.pm | 2 +- > Koha/Patron/Debarments.pm | 22 +++++---- > Koha/Patron/Discharge.pm | 2 +- > misc/cronjobs/cleanup_database.pl | 1 + > t/db_dependent/Circulation.t | 1 + > .../Circulation/MarkIssueReturned.t | 2 +- > t/db_dependent/Patron/Borrower_Debarments.t | 48 +++++++++---------- > t/db_dependent/api/v1/patrons.t | 2 +- > 8 files changed, 43 insertions(+), 37 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index d8a1cf1a65b..c2edf81f949 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -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; >diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm >index 856c93d740a..52e10368508 100644 >--- a/Koha/Patron/Debarments.pm >+++ b/Koha/Patron/Debarments.pm >@@ -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 > >diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm >index 8ad1696bc5d..76e04e8533a 100644 >--- a/Koha/Patron/Discharge.pm >+++ b/Koha/Patron/Discharge.pm >@@ -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) = @_; >diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl >index 9b4f299b911..abc7d180da1 100755 >--- a/misc/cronjobs/cleanup_database.pl >+++ b/misc/cronjobs/cleanup_database.pl >@@ -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; >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 9e9ffaf3c67..3000753a92b 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -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; >diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t >index e7b1d44421c..094276ffb4b 100755 >--- a/t/db_dependent/Circulation/MarkIssueReturned.t >+++ b/t/db_dependent/Circulation/MarkIssueReturned.t >@@ -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; >diff --git a/t/db_dependent/Patron/Borrower_Debarments.t b/t/db_dependent/Patron/Borrower_Debarments.t >index c07b80935b7..21a54eff236 100755 >--- a/t/db_dependent/Patron/Borrower_Debarments.t >+++ b/t/db_dependent/Patron/Borrower_Debarments.t >@@ -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, >diff --git a/t/db_dependent/api/v1/patrons.t b/t/db_dependent/api/v1/patrons.t >index ed8e7bec13e..c3726f54bbe 100755 >--- a/t/db_dependent/api/v1/patrons.t >+++ b/t/db_dependent/api/v1/patrons.t >@@ -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); > >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29395
: 127230