|
Lines 516-522
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
Link Here
|
| 516 |
}; |
516 |
}; |
| 517 |
|
517 |
|
| 518 |
subtest 'get_overdues' => sub { |
518 |
subtest 'get_overdues' => sub { |
| 519 |
plan tests => 3; |
519 |
plan tests => 7; |
| 520 |
|
520 |
|
| 521 |
my $library = $builder->build( { source => 'Branch' } ); |
521 |
my $library = $builder->build( { source => 'Branch' } ); |
| 522 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
522 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
|
Lines 568-581
subtest 'get_overdues' => sub {
Link Here
|
| 568 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
568 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
| 569 |
AddIssue( $patron, $item_3->{barcode} ); |
569 |
AddIssue( $patron, $item_3->{barcode} ); |
| 570 |
|
570 |
|
| 571 |
my $overdues = C4::Members::GetOverduesForPatron( $patron->{borrowernumber} ); |
571 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 572 |
is( @$overdues, 2, 'GetOverduesForPatron should return the correct number of elements' ); |
572 |
my $overdues = $patron->get_overdues; |
| 573 |
is( $overdues->[0]->{itemnumber}, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
573 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
| 574 |
is( $overdues->[1]->{itemnumber}, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
574 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
|
|
575 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
| 576 |
|
| 577 |
my $o = $overdues->reset->next; |
| 578 |
my $unblessed_overdue = $o->unblessed_all_relateds; |
| 579 |
is( exists( $unblessed_overdue->{issuedate} ), 1, 'Fields from the issues table should be filled' ); |
| 580 |
is( exists( $unblessed_overdue->{itemcallnumber} ), 1, 'Fields from the items table should be filled' ); |
| 581 |
is( exists( $unblessed_overdue->{title} ), 1, 'Fields from the biblio table should be filled' ); |
| 582 |
is( exists( $unblessed_overdue->{itemtype} ), 1, 'Fields from the biblioitems table should be filled' ); |
| 575 |
|
583 |
|
| 576 |
# Clean stuffs |
584 |
# Clean stuffs |
| 577 |
Koha::Issues->search( { borrowernumber => $patron->{borrowernumber} } )->delete; |
585 |
Koha::Issues->search( { borrowernumber => $patron->borrowernumber } )->delete; |
| 578 |
Koha::Patrons->find( $patron->{borrowernumber} )->delete; |
586 |
$patron->delete; |
| 579 |
}; |
587 |
}; |
| 580 |
|
588 |
|
| 581 |
$retrieved_patron_1->delete; |
589 |
$retrieved_patron_1->delete; |
| 582 |
- |
|
|