From c2d4dc3acfea9fd073b4405a52c82b94daffb2e5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 27 Apr 2022 13:33:09 +0200 Subject: [PATCH] Bug 30420: Rename Koha::Patron->get_overdues with ->overdues Signed-off-by: Martin Renvoize --- Koha/Patron.pm | 8 +++----- circ/circulation.pl | 2 +- members/print_overdues.pl | 2 +- t/db_dependent/Koha/Object.t | 2 +- t/db_dependent/Koha/Patrons.t | 10 +++++----- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 266e60846c..f8d9cdd39c 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1194,15 +1194,15 @@ sub old_checkouts { return Koha::Old::Checkouts->_new_from_dbic( $old_checkouts ); } -=head3 get_overdues +=head3 overdues -my $overdue_items = $patron->get_overdues +my $overdue_items = $patron->overdues Return the overdue items =cut -sub get_overdues { +sub overdues { my ($self) = @_; my $dtf = Koha::Database->new->schema->storage->datetime_parser; return $self->checkouts->search( @@ -1215,8 +1215,6 @@ sub get_overdues { ); } -sub overdues { my $self = shift; return $self->get_overdues(@_); } - =head3 get_routing_lists my $routinglists = $patron->get_routing_lists diff --git a/circ/circulation.pl b/circ/circulation.pl index dfa5cb1fd7..768bb540ec 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -241,7 +241,7 @@ if ($patron) { $template->param( borrowernumber => $patron->borrowernumber ); output_and_exit_if_error( $query, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); - my $overdues = $patron->get_overdues; + my $overdues = $patron->overdues; my $issues = $patron->checkouts; $balance = $patron->account->balance; diff --git a/members/print_overdues.pl b/members/print_overdues.pl index 1fd226d996..beb89863be 100755 --- a/members/print_overdues.pl +++ b/members/print_overdues.pl @@ -49,7 +49,7 @@ my $patron = Koha::Patrons->find( $borrowernumber ); output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); my $overdues = [ - map { $_->unblessed_all_relateds } $patron->get_overdues->as_list + map { $_->unblessed_all_relateds } $patron->overdues->as_list ]; my $letter = parse_overdues_letter( diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t index 10c94c38e3..4adafcb317 100755 --- a/t/db_dependent/Koha/Object.t +++ b/t/db_dependent/Koha/Object.t @@ -871,7 +871,7 @@ subtest 'unblessed_all_relateds' => sub { ); my $issue = AddIssue( $patron->unblessed, $item->barcode, DateTime->now->subtract( days => 1 ) ); - my $overdues = Koha::Patrons->find( $patron->id )->get_overdues; # Koha::Patron->get_overdue prefetches + my $overdues = Koha::Patrons->find( $patron->id )->overdues; # Koha::Patron->overdues prefetches my $overdue = $overdues->next->unblessed_all_relateds; is( $overdue->{issue_id}, $issue->issue_id, 'unblessed_all_relateds has field from the original table (issues)' ); is( $overdue->{title}, $biblio->title, 'unblessed_all_relateds has field from other tables (biblio)' ); diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index c8b4d4f3d6..8e37b4bb69 100755 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -558,7 +558,7 @@ subtest 'add_enrolment_fee_if_needed' => sub { $patron->delete; }; -subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { +subtest 'checkouts + pending_checkouts + overdues + old_checkouts' => sub { plan tests => 17; my $library = $builder->build( { source => 'Branch' } ); @@ -620,9 +620,9 @@ subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { my $first_checkout = $pending_checkouts->next; is( $first_checkout->unblessed_all_relateds->{biblionumber}, $item_3->biblionumber, 'pending_checkouts should prefetch values from other tables (here biblio)' ); - my $overdues = $patron->get_overdues; + my $overdues = $patron->overdues; is( $overdues->count, 2, 'Patron should have 2 overdues'); - is( ref($overdues), 'Koha::Checkouts', 'Koha::Patron->get_overdues should return Koha::Checkouts' ); + is( ref($overdues), 'Koha::Checkouts', 'Koha::Patron->overdues should return Koha::Checkouts' ); is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' ); is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' ); @@ -1419,7 +1419,7 @@ subtest 'is_child | is_adult' => sub { $patron_other->delete; }; -subtest 'get_overdues' => sub { +subtest 'overdues' => sub { plan tests => 7; my $library = $builder->build( { source => 'Branch' } ); @@ -1456,7 +1456,7 @@ subtest 'get_overdues' => sub { AddIssue( $patron, $item_3->barcode ); $patron = Koha::Patrons->find( $patron->{borrowernumber} ); - my $overdues = $patron->get_overdues; + my $overdues = $patron->overdues; is( $overdues->count, 2, 'Patron should have 2 overdues'); is( $overdues->next->itemnumber, $item_1->itemnumber, 'The issue should be returned in the same order as they have been done, first is correct' ); is( $overdues->next->itemnumber, $item_2->itemnumber, 'The issue should be returned in the same order as they have been done, second is correct' ); -- 2.20.1