|
Lines 19-31
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 23; |
22 |
use Test::More tests => 24; |
| 23 |
use Test::Warn; |
23 |
use Test::Warn; |
| 24 |
use Time::Fake; |
24 |
use Time::Fake; |
| 25 |
use DateTime; |
25 |
use DateTime; |
| 26 |
|
26 |
|
| 27 |
use C4::Biblio; |
27 |
use C4::Biblio; |
| 28 |
use C4::Circulation; |
28 |
use C4::Circulation; |
|
|
29 |
|
| 29 |
use C4::Members; |
30 |
use C4::Members; |
| 30 |
use C4::Circulation; |
31 |
use C4::Circulation; |
| 31 |
|
32 |
|
|
Lines 955-960
subtest 'account_locked' => sub {
Link Here
|
| 955 |
$patron->delete; |
956 |
$patron->delete; |
| 956 |
}; |
957 |
}; |
| 957 |
|
958 |
|
|
|
959 |
subtest 'get_overdues' => sub { |
| 960 |
plan tests => 7; |
| 961 |
|
| 962 |
my $library = $builder->build( { source => 'Branch' } ); |
| 963 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
| 964 |
my $item_1 = $builder->build( |
| 965 |
{ |
| 966 |
source => 'Item', |
| 967 |
value => { |
| 968 |
homebranch => $library->{branchcode}, |
| 969 |
holdingbranch => $library->{branchcode}, |
| 970 |
biblionumber => $biblionumber_1 |
| 971 |
} |
| 972 |
} |
| 973 |
); |
| 974 |
my $item_2 = $builder->build( |
| 975 |
{ |
| 976 |
source => 'Item', |
| 977 |
value => { |
| 978 |
homebranch => $library->{branchcode}, |
| 979 |
holdingbranch => $library->{branchcode}, |
| 980 |
biblionumber => $biblionumber_1 |
| 981 |
} |
| 982 |
} |
| 983 |
); |
| 984 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
| 985 |
my $item_3 = $builder->build( |
| 986 |
{ |
| 987 |
source => 'Item', |
| 988 |
value => { |
| 989 |
homebranch => $library->{branchcode}, |
| 990 |
holdingbranch => $library->{branchcode}, |
| 991 |
biblionumber => $biblionumber_2 |
| 992 |
} |
| 993 |
} |
| 994 |
); |
| 995 |
my $patron = $builder->build( |
| 996 |
{ |
| 997 |
source => 'Borrower', |
| 998 |
value => { branchcode => $library->{branchcode} } |
| 999 |
} |
| 1000 |
); |
| 1001 |
|
| 1002 |
my $module = new Test::MockModule('C4::Context'); |
| 1003 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
| 1004 |
|
| 1005 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
| 1006 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
| 1007 |
AddIssue( $patron, $item_3->{barcode} ); |
| 1008 |
|
| 1009 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
| 1010 |
my $overdues = $patron->get_overdues; |
| 1011 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
| 1012 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
| 1013 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
| 1014 |
|
| 1015 |
my $o = $overdues->reset->next; |
| 1016 |
my $unblessed_overdue = $o->unblessed_all_relateds; |
| 1017 |
is( exists( $unblessed_overdue->{issuedate} ), 1, 'Fields from the issues table should be filled' ); |
| 1018 |
is( exists( $unblessed_overdue->{itemcallnumber} ), 1, 'Fields from the items table should be filled' ); |
| 1019 |
is( exists( $unblessed_overdue->{title} ), 1, 'Fields from the biblio table should be filled' ); |
| 1020 |
is( exists( $unblessed_overdue->{itemtype} ), 1, 'Fields from the biblioitems table should be filled' ); |
| 1021 |
|
| 1022 |
# Clean stuffs |
| 1023 |
$patron->checkouts->delete; |
| 1024 |
$patron->delete; |
| 1025 |
}; |
| 1026 |
|
| 958 |
$retrieved_patron_1->delete; |
1027 |
$retrieved_patron_1->delete; |
| 959 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
1028 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
| 960 |
|
1029 |
|