|
Lines 8-14
use Koha::DateUtils;
Link Here
|
| 8 |
use t::lib::Mocks; |
8 |
use t::lib::Mocks; |
| 9 |
use t::lib::TestBuilder; |
9 |
use t::lib::TestBuilder; |
| 10 |
|
10 |
|
| 11 |
use Test::More tests => 11; |
11 |
use Test::More tests => 13; |
| 12 |
|
12 |
|
| 13 |
use_ok('C4::Reserves'); |
13 |
use_ok('C4::Reserves'); |
| 14 |
|
14 |
|
|
Lines 83-88
my $biblio4 = $builder->build({
Link Here
|
| 83 |
title => 'Title 4', }, |
83 |
title => 'Title 4', }, |
| 84 |
}); |
84 |
}); |
| 85 |
|
85 |
|
|
|
86 |
my $biblio5 = $builder->build({ |
| 87 |
source => 'Biblio', |
| 88 |
value => { |
| 89 |
title => 'Title 5', }, |
| 90 |
}); |
| 91 |
|
| 92 |
my $biblio6 = $builder->build({ |
| 93 |
source => 'Biblio', |
| 94 |
value => { |
| 95 |
title => 'Title 6', }, |
| 96 |
}); |
| 97 |
|
| 86 |
my $item1 = $builder->build({ |
98 |
my $item1 = $builder->build({ |
| 87 |
source => 'Item', |
99 |
source => 'Item', |
| 88 |
value => { |
100 |
value => { |
|
Lines 111-116
my $item4 = $builder->build({
Link Here
|
| 111 |
}, |
123 |
}, |
| 112 |
}); |
124 |
}); |
| 113 |
|
125 |
|
|
|
126 |
my $item5 = $builder->build({ |
| 127 |
source => 'Item', |
| 128 |
value => { |
| 129 |
biblionumber => $biblio5->{biblionumber}, |
| 130 |
}, |
| 131 |
}); |
| 132 |
|
| 133 |
my $item6 = $builder->build({ |
| 134 |
source => 'Item', |
| 135 |
value => { |
| 136 |
biblionumber => $biblio6->{biblionumber}, |
| 137 |
}, |
| 138 |
}); |
| 139 |
|
| 140 |
Koha::CirculationRules->set_rules({ |
| 141 |
categorycode => undef, |
| 142 |
itemtype => undef, |
| 143 |
branchcode => undef, |
| 144 |
rules => { |
| 145 |
holds_pickup_period => undef, |
| 146 |
} |
| 147 |
}); |
| 148 |
|
| 114 |
my $today = dt_from_string(); |
149 |
my $today = dt_from_string(); |
| 115 |
|
150 |
|
| 116 |
my $reserve1_reservedate = $today->clone; |
151 |
my $reserve1_reservedate = $today->clone; |
|
Lines 241-244
ModReserveAffect( $item4->{itemnumber}, $patron2->{borrowernumber}, 0, $reserve4
Link Here
|
| 241 |
my $r4 = Koha::Holds->find($reserve4->{reserve_id}); |
276 |
my $r4 = Koha::Holds->find($reserve4->{reserve_id}); |
| 242 |
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' ); |
277 |
is($r4->expirationdate, $requested_expiredate->ymd, 'Requested expiration date should be kept' ); |
| 243 |
|
278 |
|
|
|
279 |
Koha::CirculationRules->set_rules({ |
| 280 |
categorycode => $patron1->{categorycode}, |
| 281 |
itemtype => undef, |
| 282 |
branchcode => undef, |
| 283 |
rules => { |
| 284 |
holds_pickup_period => '3', |
| 285 |
} |
| 286 |
}); |
| 287 |
t::lib::Mocks::mock_preference('ReservesMaxPickUpDelay', 7); |
| 288 |
|
| 289 |
my $reserve5_reservedate = $today->clone; |
| 290 |
my $reserve5_expirationdate = $reserve5_reservedate->add(days => 3); |
| 291 |
|
| 292 |
my $reserve5 = $builder->build({ |
| 293 |
source => 'Reserve', |
| 294 |
value => { |
| 295 |
borrowernumber => $patron1->{borrowernumber}, |
| 296 |
reservedate => $reserve5_reservedate->ymd, |
| 297 |
expirationdate => undef, |
| 298 |
biblionumber => $biblio5->{biblionumber}, |
| 299 |
branchcode => 'LIB2', |
| 300 |
priority => 1, |
| 301 |
found => '', |
| 302 |
}, |
| 303 |
}); |
| 304 |
|
| 305 |
ModReserveAffect( $item5->{itemnumber}, $patron1->{borrowernumber}); |
| 306 |
my $r5 = Koha::Holds->find($reserve5->{reserve_id}); |
| 307 |
|
| 308 |
is($r5->expirationdate, $reserve5_expirationdate->ymd, 'Expiration date should be set to today + 3 based on circulation rules' ); |
| 309 |
|
| 310 |
my $reserve6_reservedate = $today->clone; |
| 311 |
# add 3 days of pickup + 1 day of holiday |
| 312 |
my $reserve6_expirationdate = $reserve6_reservedate->add(days => 5); |
| 313 |
|
| 314 |
my $reserve6 = $builder->build({ |
| 315 |
source => 'Reserve', |
| 316 |
value => { |
| 317 |
borrowernumber => $patron1->{borrowernumber}, |
| 318 |
reservedate => $reserve6_reservedate->ymd, |
| 319 |
expirationdate => undef, |
| 320 |
biblionumber => $biblio6->{biblionumber}, |
| 321 |
branchcode => 'LIB1', |
| 322 |
priority => 1, |
| 323 |
found => '', |
| 324 |
}, |
| 325 |
}); |
| 326 |
|
| 327 |
ModReserveAffect( $item6->{itemnumber}, $patron1->{borrowernumber}); |
| 328 |
my $r6 = Koha::Holds->find($reserve6->{reserve_id}); |
| 329 |
|
| 330 |
is($r6->expirationdate, $reserve6_expirationdate->ymd, 'Expiration date should be set to today + 4 based on circulation rules and including a holiday' ); |
| 331 |
|
| 244 |
$schema->storage->txn_rollback; |
332 |
$schema->storage->txn_rollback; |
| 245 |
- |
|
|