Lines 19-31
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 25; |
22 |
use Test::More tests => 26; |
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 1118-1123
subtest 'is_child | is_adult' => sub {
Link Here
|
1118 |
$patron_other->delete; |
1119 |
$patron_other->delete; |
1119 |
}; |
1120 |
}; |
1120 |
|
1121 |
|
|
|
1122 |
subtest 'get_overdues' => sub { |
1123 |
plan tests => 7; |
1124 |
|
1125 |
my $library = $builder->build( { source => 'Branch' } ); |
1126 |
my ($biblionumber_1) = AddBiblio( MARC::Record->new, '' ); |
1127 |
my $item_1 = $builder->build( |
1128 |
{ |
1129 |
source => 'Item', |
1130 |
value => { |
1131 |
homebranch => $library->{branchcode}, |
1132 |
holdingbranch => $library->{branchcode}, |
1133 |
biblionumber => $biblionumber_1 |
1134 |
} |
1135 |
} |
1136 |
); |
1137 |
my $item_2 = $builder->build( |
1138 |
{ |
1139 |
source => 'Item', |
1140 |
value => { |
1141 |
homebranch => $library->{branchcode}, |
1142 |
holdingbranch => $library->{branchcode}, |
1143 |
biblionumber => $biblionumber_1 |
1144 |
} |
1145 |
} |
1146 |
); |
1147 |
my ($biblionumber_2) = AddBiblio( MARC::Record->new, '' ); |
1148 |
my $item_3 = $builder->build( |
1149 |
{ |
1150 |
source => 'Item', |
1151 |
value => { |
1152 |
homebranch => $library->{branchcode}, |
1153 |
holdingbranch => $library->{branchcode}, |
1154 |
biblionumber => $biblionumber_2 |
1155 |
} |
1156 |
} |
1157 |
); |
1158 |
my $patron = $builder->build( |
1159 |
{ |
1160 |
source => 'Borrower', |
1161 |
value => { branchcode => $library->{branchcode} } |
1162 |
} |
1163 |
); |
1164 |
|
1165 |
my $module = new Test::MockModule('C4::Context'); |
1166 |
$module->mock( 'userenv', sub { { branch => $library->{branchcode} } } ); |
1167 |
|
1168 |
AddIssue( $patron, $item_1->{barcode}, DateTime->now->subtract( days => 1 ) ); |
1169 |
AddIssue( $patron, $item_2->{barcode}, DateTime->now->subtract( days => 5 ) ); |
1170 |
AddIssue( $patron, $item_3->{barcode} ); |
1171 |
|
1172 |
$patron = Koha::Patrons->find( $patron->{borrowernumber} ); |
1173 |
my $overdues = $patron->get_overdues; |
1174 |
is( $overdues->count, 2, 'Patron should have 2 overdues'); |
1175 |
is( $overdues->next->itemnumber, $item_1->{itemnumber}, 'The issue should be returned in the same order as they have been done, first is correct' ); |
1176 |
is( $overdues->next->itemnumber, $item_2->{itemnumber}, 'The issue should be returned in the same order as they have been done, second is correct' ); |
1177 |
|
1178 |
my $o = $overdues->reset->next; |
1179 |
my $unblessed_overdue = $o->unblessed_all_relateds; |
1180 |
is( exists( $unblessed_overdue->{issuedate} ), 1, 'Fields from the issues table should be filled' ); |
1181 |
is( exists( $unblessed_overdue->{itemcallnumber} ), 1, 'Fields from the items table should be filled' ); |
1182 |
is( exists( $unblessed_overdue->{title} ), 1, 'Fields from the biblio table should be filled' ); |
1183 |
is( exists( $unblessed_overdue->{itemtype} ), 1, 'Fields from the biblioitems table should be filled' ); |
1184 |
|
1185 |
# Clean stuffs |
1186 |
$patron->checkouts->delete; |
1187 |
$patron->delete; |
1188 |
}; |
1189 |
|
1121 |
$retrieved_patron_1->delete; |
1190 |
$retrieved_patron_1->delete; |
1122 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
1191 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
1123 |
|
1192 |
|