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; |
25 |
use C4::Members; |
27 |
use C4::Members; |
26 |
use C4::Circulation; |
28 |
use C4::Circulation; |
27 |
|
29 |
|
Lines 513-518
subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub {
Link Here
|
513 |
Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; |
515 |
Koha::Patrons->find( $userenv_patron->{borrowernumber})->delete; |
514 |
}; |
516 |
}; |
515 |
|
517 |
|
|
|
518 |
subtest 'get_overdues' => sub { |
519 |
plan tests => 3; |
520 |
|
521 |
my $library = $builder->build( { source => 'Branch' } ); |
522 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
523 |
my $item_1 = $builder->build( |
524 |
{ |
525 |
source => 'Item', |
526 |
value => { |
527 |
homebranch => $library->{branchcode}, |
528 |
holdingbranch => $library->{branchcode}, |
529 |
biblionumber => $biblionumber_1 |
530 |
} |
531 |
} |
532 |
); |
533 |
my $item_2 = $builder->build( |
534 |
{ |
535 |
source => 'Item', |
536 |
value => { |
537 |
homebranch => $library->{branchcode}, |
538 |
holdingbranch => $library->{branchcode}, |
539 |
biblionumber => $biblionumber_1 |
540 |
} |
541 |
} |
542 |
); |
543 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
544 |
my $item_3 = $builder->build( |
545 |
{ |
546 |
source => 'Item', |
547 |
value => { |
548 |
homebranch => $library->{branchcode}, |
549 |
holdingbranch => $library->{branchcode}, |
550 |
biblionumber => $biblionumber_2 |
551 |
} |
552 |
} |
553 |
); |
554 |
my $patron = $builder->build( |
555 |
{ |
556 |
source => 'Borrower', |
557 |
value => { branchcode => $library->{branchcode} } |
558 |
} |
559 |
); |
560 |
|
561 |
# Not sure how this is useful, but AddIssue pass this variable to different other subroutines |
562 |
$patron = GetMember( borrowernumber => $patron->{borrowernumber} ); |
563 |
|
564 |
my $module = new Test::MockModule('C4::Context'); |
565 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
566 |
|
567 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
568 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
569 |
AddIssue( $patron, $item_3->{barcode} ); |
570 |
|
571 |
my $overdues = C4::Members::GetOverduesForPatron( $patron->{borrowernumber} ); |
572 |
is( @$overdues, 2, 'GetOverduesForPatron should return the correct number of elements' ); |
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' ); |
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' ); |
575 |
|
576 |
# Clean stuffs |
577 |
Koha::Issues->search( { borrowernumber => $patron->{borrowernumber} } )->delete; |
578 |
Koha::Patrons->find( $patron->{borrowernumber} )->delete; |
579 |
}; |
580 |
|
516 |
$retrieved_patron_1->delete; |
581 |
$retrieved_patron_1->delete; |
517 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
582 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
518 |
|
583 |
|