Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 113; |
20 |
use Test::More tests => 115; |
21 |
|
21 |
|
22 |
use DateTime; |
22 |
use DateTime; |
23 |
|
23 |
|
Lines 225-230
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
225 |
my $title = 'Silence in the library'; |
225 |
my $title = 'Silence in the library'; |
226 |
my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven'); |
226 |
my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven'); |
227 |
|
227 |
|
|
|
228 |
|
228 |
my $barcode = 'R00000342'; |
229 |
my $barcode = 'R00000342'; |
229 |
my $branch = $library2->{branchcode}; |
230 |
my $branch = $library2->{branchcode}; |
230 |
|
231 |
|
Lines 331-336
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
331 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $itemnumber } )->borrowernumber; |
332 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $itemnumber } )->borrowernumber; |
332 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
333 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
333 |
|
334 |
|
|
|
335 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
334 |
my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1); |
336 |
my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1); |
335 |
is( $renewokay, 1, 'Can renew, no holds for this title or item'); |
337 |
is( $renewokay, 1, 'Can renew, no holds for this title or item'); |
336 |
|
338 |
|
Lines 1153-1158
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
1153 |
} |
1155 |
} |
1154 |
|
1156 |
|
1155 |
{ |
1157 |
{ |
|
|
1158 |
# Don't allow renewing on reserve period with PreventCheckoutOnSameReservePeriod enabled |
1159 |
t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 1 ); |
1160 |
|
1161 |
my $start_issue_dt = DateTime->now(); |
1162 |
$start_issue_dt->subtract( days => 15); |
1163 |
my $due_date = $start_issue_dt->clone; |
1164 |
$due_date->add( days => 17 ); |
1165 |
|
1166 |
my $biblio = $builder->build({ |
1167 |
source => 'Biblio', |
1168 |
}); |
1169 |
my $biblionumber = $biblio->{biblionumber}; |
1170 |
|
1171 |
my $item = $builder->build({ |
1172 |
source => 'Item', |
1173 |
value => { |
1174 |
biblionumber => $biblionumber |
1175 |
} |
1176 |
}); |
1177 |
my $itemnumber = $item->{itemnumber}; |
1178 |
|
1179 |
my $issue = $builder->build({ |
1180 |
source => 'Issue', |
1181 |
value => { |
1182 |
itemnumber => $itemnumber, |
1183 |
biblionumber => $biblionumber, |
1184 |
issuedate => $start_issue_dt->ymd, |
1185 |
date_due => $due_date->ymd, |
1186 |
onsite_checkout => 0 |
1187 |
} |
1188 |
}); |
1189 |
|
1190 |
my $reservedate = $due_date->clone; |
1191 |
$reservedate->add( days => 5 ); |
1192 |
my $expirationdate = $reservedate->clone; |
1193 |
$expirationdate->add( days => 15 ); |
1194 |
$builder->build({ |
1195 |
source => 'Reserve', |
1196 |
value => { |
1197 |
biblionumber => $biblionumber, |
1198 |
itemnumber => $itemnumber, |
1199 |
reservedate => $reservedate->ymd, |
1200 |
expirationdate => $expirationdate->ymd |
1201 |
} |
1202 |
}); |
1203 |
|
1204 |
my $requested_date_due = $due_date->clone; |
1205 |
$requested_date_due->add( days => 4 ); |
1206 |
my ( $renewed, $error ) = CanBookBeRenewed( $issue->{borrowernumber}, $itemnumber, 1, $requested_date_due ); |
1207 |
is( $renewed, 1, 'CanBookBeRenewed should allow to renew if no reserve date overlap' ); |
1208 |
|
1209 |
$requested_date_due->add( days => 2 ); |
1210 |
( $renewed, $error ) = CanBookBeRenewed( $issue->{borrowernumber}, $itemnumber, 1, $requested_date_due ); |
1211 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew if reserve date overlap' ); |
1212 |
|
1213 |
t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 0 ); |
1214 |
} |
1215 |
|
1216 |
{ |
1156 |
my $library = $builder->build({ source => 'Branch' }); |
1217 |
my $library = $builder->build({ source => 'Branch' }); |
1157 |
|
1218 |
|
1158 |
my ($biblionumber, $biblioitemnumber) = add_biblio(); |
1219 |
my ($biblionumber, $biblioitemnumber) = add_biblio(); |
1159 |
- |
|
|