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>
-my $issues = $patron->checkouts
+my $checkouts = $patron->checkouts
=cut
sub checkouts {
my ($self) = @_;
=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 );
-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, '' );
my $library = $builder->build( { source => 'Branch' } );
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' );
value => {
homebranch => $library->{branchcode},
holdingbranch => $library->{branchcode},
value => {
homebranch => $library->{branchcode},
holdingbranch => $library->{branchcode},
- biblionumber => $biblionumber_1
+ biblionumber => $biblionumber_1,
+ itemlost => 0,
+ withdrawn => 0,
value => {
homebranch => $library->{branchcode},
holdingbranch => $library->{branchcode},
value => {
homebranch => $library->{branchcode},
holdingbranch => $library->{branchcode},
- biblionumber => $biblionumber_1
+ biblionumber => $biblionumber_1,
+ itemlost => 0,
+ withdrawn => 0,
value => {
homebranch => $library->{branchcode},
holdingbranch => $library->{branchcode},
value => {
homebranch => $library->{branchcode},
holdingbranch => $library->{branchcode},
- biblionumber => $biblionumber_2
+ biblionumber => $biblionumber_2,
+ itemlost => 0,
+ withdrawn => 0,
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 $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 = Koha::Patrons->find( $patron->borrowernumber )->unblessed;
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines
$patron = Koha::Patrons->find( $patron->borrowernumber )->unblessed;
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' );
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;
# Clean stuffs
Koha::Checkouts->search( { borrowernumber => $patron->borrowernumber } )->delete;
$patron->delete;