|
Lines 19-27
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 12; |
22 |
use Test::More tests => 13; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
|
|
24 |
use DateTime; |
| 24 |
|
25 |
|
|
|
26 |
use C4::Biblio; |
| 27 |
use C4::Circulation; |
| 25 |
use C4::Members; |
28 |
use C4::Members; |
| 26 |
use C4::Circulation; |
29 |
use C4::Circulation; |
| 27 |
|
30 |
|
|
Lines 513-518
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
Link Here
|
| 513 |
Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; |
516 |
Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; |
| 514 |
}; |
517 |
}; |
| 515 |
|
518 |
|
|
|
519 |
subtest 'get_overdues' => sub { |
| 520 |
plan tests => 4; |
| 521 |
|
| 522 |
my $library = $builder->build( { source => 'Branch' } ); |
| 523 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
| 524 |
my $item_1 = $builder->build( |
| 525 |
{ |
| 526 |
source => 'Item', |
| 527 |
value => { |
| 528 |
homebranch => $library->{branchcode}, |
| 529 |
holdingbranch => $library->{branchcode}, |
| 530 |
biblionumber => $biblionumber_1 |
| 531 |
} |
| 532 |
} |
| 533 |
); |
| 534 |
my $item_2 = $builder->build( |
| 535 |
{ |
| 536 |
source => 'Item', |
| 537 |
value => { |
| 538 |
homebranch => $library->{branchcode}, |
| 539 |
holdingbranch => $library->{branchcode}, |
| 540 |
biblionumber => $biblionumber_1 |
| 541 |
} |
| 542 |
} |
| 543 |
); |
| 544 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
| 545 |
my $item_3 = $builder->build( |
| 546 |
{ |
| 547 |
source => 'Item', |
| 548 |
value => { |
| 549 |
homebranch => $library->{branchcode}, |
| 550 |
holdingbranch => $library->{branchcode}, |
| 551 |
biblionumber => $biblionumber_2 |
| 552 |
} |
| 553 |
} |
| 554 |
); |
| 555 |
my $patron = $builder->build( |
| 556 |
{ |
| 557 |
source => 'Borrower', |
| 558 |
value => { branchcode => $library->{branchcode} } |
| 559 |
} |
| 560 |
); |
| 561 |
|
| 562 |
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines |
| 563 |
$patron = GetMember( borrowernumber => $patron->{borrowernumber} ); |
| 564 |
|
| 565 |
my $module = new Test::MockModule('C4::Context'); |
| 566 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
| 567 |
|
| 568 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
| 569 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
| 570 |
AddIssue( $patron, $item_3->{barcode} ); |
| 571 |
|
| 572 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 573 |
my $overdues = $patron->get_overdues; |
| 574 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
| 575 |
is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' ); |
| 576 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
| 577 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
| 578 |
|
| 579 |
# Clean stuffs |
| 580 |
Koha::Issues->search( { borrowernumber => $patron->borrowernumber } )->delete; |
| 581 |
$patron->delete; |
| 582 |
}; |
| 583 |
|
| 516 |
$retrieved_patron_1->delete; |
584 |
$retrieved_patron_1->delete; |
| 517 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
585 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
| 518 |
|
586 |
|
| 519 |
- |
|
|