|
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 531-536
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
Link Here
|
| 531 |
Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; |
534 |
Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; |
| 532 |
}; |
535 |
}; |
| 533 |
|
536 |
|
|
|
537 |
subtest 'get_overdues' => sub { |
| 538 |
plan tests => 4; |
| 539 |
|
| 540 |
my $library = $builder->build( { source => 'Branch' } ); |
| 541 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
| 542 |
my $item_1 = $builder->build( |
| 543 |
{ |
| 544 |
source => 'Item', |
| 545 |
value => { |
| 546 |
homebranch => $library->{branchcode}, |
| 547 |
holdingbranch => $library->{branchcode}, |
| 548 |
biblionumber => $biblionumber_1 |
| 549 |
} |
| 550 |
} |
| 551 |
); |
| 552 |
my $item_2 = $builder->build( |
| 553 |
{ |
| 554 |
source => 'Item', |
| 555 |
value => { |
| 556 |
homebranch => $library->{branchcode}, |
| 557 |
holdingbranch => $library->{branchcode}, |
| 558 |
biblionumber => $biblionumber_1 |
| 559 |
} |
| 560 |
} |
| 561 |
); |
| 562 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
| 563 |
my $item_3 = $builder->build( |
| 564 |
{ |
| 565 |
source => 'Item', |
| 566 |
value => { |
| 567 |
homebranch => $library->{branchcode}, |
| 568 |
holdingbranch => $library->{branchcode}, |
| 569 |
biblionumber => $biblionumber_2 |
| 570 |
} |
| 571 |
} |
| 572 |
); |
| 573 |
my $patron = $builder->build( |
| 574 |
{ |
| 575 |
source => 'Borrower', |
| 576 |
value => { branchcode => $library->{branchcode} } |
| 577 |
} |
| 578 |
); |
| 579 |
|
| 580 |
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines |
| 581 |
$patron = GetMember( borrowernumber => $patron->{borrowernumber} ); |
| 582 |
|
| 583 |
my $module = new Test::MockModule('C4::Context'); |
| 584 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
| 585 |
|
| 586 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
| 587 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
| 588 |
AddIssue( $patron, $item_3->{barcode} ); |
| 589 |
|
| 590 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 591 |
my $overdues = $patron->get_overdues; |
| 592 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
| 593 |
is( ref($overdues), 'Koha::Issues', 'Koha::Patron->get_overdues should return Koha::Issues' ); |
| 594 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
| 595 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
| 596 |
|
| 597 |
# Clean stuffs |
| 598 |
Koha::Issues->search( { borrowernumber => $patron->borrowernumber } )->delete; |
| 599 |
$patron->delete; |
| 600 |
}; |
| 601 |
|
| 534 |
$retrieved_patron_1->delete; |
602 |
$retrieved_patron_1->delete; |
| 535 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
603 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
| 536 |
|
604 |
|
| 537 |
- |
|
|