From 5e5b642067bb108e4270aa8d5aab130ab3403be8 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 Signed-off-by: Tomas Cohen Arazi --- 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 e205e23fd3..e677f39e87 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1215,15 +1215,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( @@ -1236,8 +1236,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 ff5353e088..614547b65a 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -240,7 +240,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.39.5