Bug 19830: Add the Koha::Patron->old_checkouts method
Test plan:
prove t/db_dependent/Koha/Patrons.t
must return green
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 699340a398)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
parent
ce1aacf121
commit
6bd9fbbcac
|
|
@ -510,14 +510,26 @@ sub add_enrolment_fee_if_needed {
|
|||
|
||||
=head3 checkouts
|
||||
|
||||
my $issues = $patron->checkouts
|
||||
my $checkouts = $patron->checkouts
|
||||
|
||||
=cut
|
||||
|
||||
sub checkouts {
|
||||
my ($self) = @_;
|
||||
my $issues = $self->_result->issues;
|
||||
return Koha::Checkouts->_new_from_dbic( $issues );
|
||||
my $checkouts = $self->_result->issues;
|
||||
return Koha::Checkouts->_new_from_dbic( $checkouts );
|
||||
}
|
||||
|
||||
=head3 old_checkouts
|
||||
|
||||
my $old_checkouts = $patron->old_checkouts
|
||||
|
||||
=cut
|
||||
|
||||
sub old_checkouts {
|
||||
my ($self) = @_;
|
||||
my $old_checkouts = $self->_result->old_issues;
|
||||
return Koha::Old::Checkouts->_new_from_dbic( $old_checkouts );
|
||||
}
|
||||
|
||||
=head3 get_overdues
|
||||
|
|
|
|||
|
|
@ -425,8 +425,8 @@ subtest 'add_enrolment_fee_if_needed' => sub {
|
|||
$patron->delete;
|
||||
};
|
||||
|
||||
subtest 'checkouts + get_overdues' => sub {
|
||||
plan tests => 8;
|
||||
subtest 'checkouts + get_overdues + old_checkouts' => sub {
|
||||
plan tests => 12;
|
||||
|
||||
my $library = $builder->build( { source => 'Branch' } );
|
||||
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
|
||||
|
|
@ -436,7 +436,9 @@ subtest 'checkouts + get_overdues' => sub {
|
|||
value => {
|
||||
homebranch => $library->{branchcode},
|
||||
holdingbranch => $library->{branchcode},
|
||||
biblionumber => $biblionumber_1
|
||||
biblionumber => $biblionumber_1,
|
||||
itemlost => 0,
|
||||
withdrawn => 0,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -446,7 +448,9 @@ subtest 'checkouts + get_overdues' => sub {
|
|||
value => {
|
||||
homebranch => $library->{branchcode},
|
||||
holdingbranch => $library->{branchcode},
|
||||
biblionumber => $biblionumber_1
|
||||
biblionumber => $biblionumber_1,
|
||||
itemlost => 0,
|
||||
withdrawn => 0,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -457,7 +461,9 @@ subtest 'checkouts + get_overdues' => sub {
|
|||
value => {
|
||||
homebranch => $library->{branchcode},
|
||||
holdingbranch => $library->{branchcode},
|
||||
biblionumber => $biblionumber_2
|
||||
biblionumber => $biblionumber_2,
|
||||
itemlost => 0,
|
||||
withdrawn => 0,
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -472,6 +478,9 @@ subtest 'checkouts + get_overdues' => sub {
|
|||
my $checkouts = $patron->checkouts;
|
||||
is( $checkouts->count, 0, 'checkouts should not return any issues for that patron' );
|
||||
is( ref($checkouts), 'Koha::Checkouts', 'checkouts should return a Koha::Checkouts object' );
|
||||
my $old_checkouts = $patron->old_checkouts;
|
||||
is( $old_checkouts->count, 0, 'old_checkouts should not return any issues for that patron' );
|
||||
is( ref($old_checkouts), 'Koha::Old::Checkouts', 'old_checkouts should return a Koha::Old::Checkouts object' );
|
||||
|
||||
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines
|
||||
$patron = GetMember( borrowernumber => $patron->borrowernumber );
|
||||
|
|
@ -494,6 +503,13 @@ subtest 'checkouts + get_overdues' => sub {
|
|||
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' );
|
||||
|
||||
|
||||
C4::Circulation::AddReturn( $item_1->{barcode} );
|
||||
C4::Circulation::AddReturn( $item_2->{barcode} );
|
||||
$old_checkouts = $patron->old_checkouts;
|
||||
is( $old_checkouts->count, 2, 'old_checkouts should return 2 old checkouts that patron' );
|
||||
is( ref($old_checkouts), 'Koha::Old::Checkouts', 'old_checkouts should return a Koha::Old::Checkouts object' );
|
||||
|
||||
# Clean stuffs
|
||||
Koha::Checkouts->search( { borrowernumber => $patron->borrowernumber } )->delete;
|
||||
$patron->delete;
|
||||
|
|
|
|||
Loading…
Reference in New Issue